Example #1
0
        public void getAlternatingBortderCellProperties(Range cell, int row, int column)
        {
            myCell tempCell = new myCell();

            tempCell.rowIndex    = row;
            tempCell.columnIndex = column;

            //tempCell.complexWords = GetStringProperties(cell[1,1], cell[1, 1].Text);
            //tempCell.complexWords = new List<myCell.myFont>();
            //string text = cell[1, 1].Text;
            //for (int a = 0; a < text.Length+1; a++)
            //{
            //    tempCell.complexWords.Add(new myCell.myFont());
            //    Characters temp = cell[1, 1].Characters(a,1);
            //    tempCell.complexWords[a].name = temp.Font.Name;
            //    tempCell.complexWords[a].size = temp.Font.Size;
            //    tempCell.complexWords[a].color = temp.Font.Color;
            //    tempCell.complexWords[a].bold = temp.Font.Bold;
            //    tempCell.complexWords[a].italic = temp.Font.Italic;
            //    tempCell.complexWords[a].underline = temp.Font.Underline;
            //    tempCell.complexWords[a].strikeThrough = temp.Font.Strikethrough;
            //}
            tempCell.horizontalAlignment = cell[1, 1].HorizontalAlignment;
            tempCell.verticalAlignment   = cell[1, 1].VerticalAlignment;
            tempCell.text          = cell[1, 1].Text;
            tempCell.height        = cell[1, 1].RowHeight;
            tempCell.width         = cell[1, 1].ColumnWidth;
            tempCell.color         = cell[1, 1].Interior.Color;
            tempCell.merge         = cell[1, 1].MergeCells();
            tempCell.name          = cell[1, 1].Font.Name;
            tempCell.size          = cell[1, 1].Font.Size;
            tempCell.fontColor     = cell[1, 1].Font.Color;
            tempCell.bold          = cell[1, 1].Font.Bold;
            tempCell.italic        = cell[1, 1].Font.Italic;
            tempCell.underline     = cell[1, 1].Font.Underline;
            tempCell.strikeThrough = cell[1, 1].Font.Strikethrough;


            if (column % 2 == 0) // only read borders that are even column numbers to make checker pattern
            {
                tempCell.topLineStyle    = (XlLineStyle)cell[1, 1].Borders(XlBordersIndex.xlEdgeTop).LineStyle;
                tempCell.topWeight       = (XlBorderWeight)cell[1, 1].Borders(XlBordersIndex.xlEdgeTop).Weight;
                tempCell.rightLineStyle  = (XlLineStyle)cell[1, 1].Borders(XlBordersIndex.xlEdgeRight).LineStyle;
                tempCell.rightWeight     = (XlBorderWeight)cell[1, 1].Borders(XlBordersIndex.xlEdgeRight).Weight;
                tempCell.bottomLineStyle = (XlLineStyle)cell[1, 1].Borders(XlBordersIndex.xlEdgeBottom).LineStyle;
                tempCell.bottomWeight    = (XlBorderWeight)cell[1, 1].Borders(XlBordersIndex.xlEdgeBottom).Weight;
                tempCell.leftLineStyle   = (XlLineStyle)cell[1, 1].Borders(XlBordersIndex.xlEdgeLeft).LineStyle;
                tempCell.leftWeight      = (XlBorderWeight)cell[1, 1].Borders(XlBordersIndex.xlEdgeLeft).Weight;
            }

            allCells[row - 1, column - 1] = tempCell; // the -1 is because in excel you start counting from 1 not 0 and we don't want an empty cell in the
                                                      // beginning of each column and row.
        }
Example #2
0
 private void dataGridView1_CellEnter(object sender, DataGridViewCellEventArgs e)
 {
     if (!_manual || dataGridView1.SelectedCells.Count == 0)
     {
         return;
     }
     if ((_catType == CatalogType.PRODUCTS && e.ColumnIndex == 3) || dataGridView1.SelectedCells[0].Value == null)
     {
         _lastCell = null;
         return;
     }
     _lastCell = new myCell(e.ColumnIndex, e.RowIndex, dataGridView1.SelectedCells[0].Value.ToString());
 }
Example #3
0
        public void writeCheckeredData(myCell cell)
        {
            xlWorkSheet.Cells[cell.rowIndex, cell.columnIndex].Interior.Color = cell.color;
            //16777215 color of white cell
            xlWorkSheet.Cells[cell.rowIndex, cell.columnIndex].HorizontalAlignment = cell.horizontalAlignment;
            xlWorkSheet.Cells[cell.rowIndex, cell.columnIndex].VerticalAlignment   = cell.verticalAlignment;



            if (cell.columnIndex % 2 == 0) // only read borders that are even column numbers to make checker pattern
            {
                if (cell.topLineStyle == XlLineStyle.xlLineStyleNone)
                {
                    cell.topWeight = XlBorderWeight.xlHairline;
                }
                if (cell.rightLineStyle == XlLineStyle.xlLineStyleNone)
                {
                    cell.rightWeight = XlBorderWeight.xlHairline;
                }
                if (cell.bottomLineStyle == XlLineStyle.xlLineStyleNone)
                {
                    cell.bottomWeight = XlBorderWeight.xlHairline;
                }
                if (cell.leftLineStyle == XlLineStyle.xlLineStyleNone)
                {
                    cell.leftWeight = XlBorderWeight.xlHairline;
                }

                xlWorkSheet.Cells[cell.rowIndex, cell.columnIndex].Borders(XlBordersIndex.xlEdgeTop).LineStyle    = cell.topLineStyle;
                xlWorkSheet.Cells[cell.rowIndex, cell.columnIndex].Borders(XlBordersIndex.xlEdgeTop).Weight       = cell.topWeight;
                xlWorkSheet.Cells[cell.rowIndex, cell.columnIndex].Borders(XlBordersIndex.xlEdgeRight).LineStyle  = cell.rightLineStyle;
                xlWorkSheet.Cells[cell.rowIndex, cell.columnIndex].Borders(XlBordersIndex.xlEdgeRight).Weight     = cell.rightWeight;
                xlWorkSheet.Cells[cell.rowIndex, cell.columnIndex].Borders(XlBordersIndex.xlEdgeBottom).LineStyle = cell.bottomLineStyle;
                xlWorkSheet.Cells[cell.rowIndex, cell.columnIndex].Borders(XlBordersIndex.xlEdgeBottom).Weight    = cell.bottomWeight;
                xlWorkSheet.Cells[cell.rowIndex, cell.columnIndex].Borders(XlBordersIndex.xlEdgeLeft).LineStyle   = cell.leftLineStyle;
                xlWorkSheet.Cells[cell.rowIndex, cell.columnIndex].Borders(XlBordersIndex.xlEdgeLeft).Weight      = cell.leftWeight;
            }


            xlWorkSheet.Cells[cell.rowIndex, cell.columnIndex]                    = cell.text;
            xlWorkSheet.Cells[cell.rowIndex, cell.columnIndex].Font.Name          = cell.name;
            xlWorkSheet.Cells[cell.rowIndex, cell.columnIndex].Font.Size          = cell.size;
            xlWorkSheet.Cells[cell.rowIndex, cell.columnIndex].Font.Color         = cell.fontColor;
            xlWorkSheet.Cells[cell.rowIndex, cell.columnIndex].Font.Bold          = cell.bold;
            xlWorkSheet.Cells[cell.rowIndex, cell.columnIndex].Font.Italic        = cell.italic;
            xlWorkSheet.Cells[cell.rowIndex, cell.columnIndex].Font.Underline     = cell.underline;
            xlWorkSheet.Cells[cell.rowIndex, cell.columnIndex].Font.Strikethrough = cell.strikeThrough;
        }
Example #4
0
        public myCell getAllCellProperties(Range cell, int row, int column)
        {
            myCell tempCell = new myCell();
            bool   matched  = false;

            tempCell.rowIndex       = row;
            tempCell.columnIndex    = column;
            tempCell.text           = cell[1, 1].Text;
            tempCell.color          = cell[1, 1].Interior.Color;
            tempCell.rightLineStyle = (XlLineStyle)cell[1, 1].Borders(XlBordersIndex.xlEdgeRight).LineStyle; // ignoring top border because it would overwrite header
            tempCell.rightWeight    = (XlBorderWeight)cell[1, 1].Borders(XlBordersIndex.xlEdgeRight).Weight;
            if (tempCell.text.Contains("[TextHere]"))
            {
                tempCell.text = tempCell.text.Split(':')[0]; titleBlock.Add(tempCell); return(tempCell);
            }
            else if (tempCell.text.Contains("[HeaderHere]"))
            {
                tempCell.text = tempCell.text.Split('[')[0]; headerRow.Add(tempCell); tempCell.info = tempCell.text; return(tempCell);
            }
            else if (tempCell.text.Contains("[BodyHere]"))
            {
                if (currentRow != row)
                {
                    bodyRows.Add(new List <myCell>());
                    bodyColors.Add(cell[1, 1].Interior.Color);
                }
                currentRow = row;
                if (tempCell.color != 16777215)
                {
                    tempCell.moreThanText = true;
                }
                if (tempCell.rightLineStyle != XlLineStyle.xlLineStyleNone) // only add border style to cell class if it is other than the expected default.
                {
                    tempCell.moreThanText    = true;
                    tempCell.rightLineStyle  = (XlLineStyle)cell[1, 1].Borders(XlBordersIndex.xlEdgeRight).LineStyle; // ignoring top border because it would overwrite header
                    tempCell.rightWeight     = (XlBorderWeight)cell[1, 1].Borders(XlBordersIndex.xlEdgeRight).Weight;
                    tempCell.bottomLineStyle = (XlLineStyle)cell[1, 1].Borders(XlBordersIndex.xlEdgeBottom).LineStyle;
                    tempCell.bottomWeight    = (XlBorderWeight)cell[1, 1].Borders(XlBordersIndex.xlEdgeBottom).Weight;
                    tempCell.leftLineStyle   = (XlLineStyle)cell[1, 1].Borders(XlBordersIndex.xlEdgeLeft).LineStyle;
                    tempCell.leftWeight      = (XlBorderWeight)cell[1, 1].Borders(XlBordersIndex.xlEdgeLeft).Weight;
                }
                bodyRows[bodyRows.Count - 1].Add(tempCell);
                return(tempCell);
            }
            else if (tempCell.text.Contains("[Sort]"))
            {
                string[] sortInfo = tempCell.text.Split(']')[1].Split('('); // possible cell content [Sort](1)P,C,CN,L,R(4)incrementing
                int      sortNum  = sortInfo.Length;
                for (int a = 1; a < sortNum; a++)
                {
                    sortOrder.Add(new List <string>());
                    string[] tempDelimiter = sortInfo[a].Split(')')[1].Split(',');
                    sortOrder[sortOrder.Count - 1].Add(sortInfo[a].Split(')')[0]);
                    sortOrder[sortOrder.Count - 1].Add((column - 1).ToString());
                    foreach (string tempString in tempDelimiter)
                    {
                        sortOrder[sortOrder.Count - 1].Add(tempString);                                          // should make above cell entry into { {1, *column* , *sortType* P,C,CN,L,R} , {4, *column*, incrementing} }
                    }
                }
                return(tempCell);
            }
            else if (tempCell.text.Contains("[Footer]"))
            {
                footerColor = (int)tempCell.color;
                footerList.Add(tempCell.text.Split(']')[1]);
            }
            else if (tempCell.text.Contains("[Group]"))
            {
                group.Add(column - 1);
            }
            else if (tempCell.text.Contains("[Quantity]"))
            {
                quantity = column - 1;
            }
            else if (tempCell.text.Contains("[EndRow]"))
            {
                rowEnd = row;
                return(tempCell);
            }
            else if (tempCell.text.Contains("[EndColumn]"))
            {
                columnEnd = column;
                return(tempCell);
            }
            return(tempCell);
        }