예제 #1
0
        public ExcelSheetData GetSheetData()
        {
            ExcelSheetData data = new ExcelSheetData();

            ExcelRangeInfo lastCell = GetLastCellCoords();

            int numberOfRows    = lastCell.Start.Row;
            int numberOfColumns = lastCell.Start.Column;

            int iRow = 1;

            for (int r = 1; r <= numberOfRows; ++r)
            {
                object[] values = new object[numberOfColumns];
                for (int c = 1; c <= numberOfColumns; ++c)
                {
                    Range cellRange = GetCell(r, c);
                    values[c - 1] = cellRange.Value2;
                }

                ExcelRowData rowData = new ExcelRowData(1, iRow, values);
                data.Rows.Add(rowData);
                iRow++;
            }

            return(data);
        }
예제 #2
0
        public ExcelSheetData CreateFromGrid(DataGridView grid)
        {
            ExcelSheetData data = new ExcelSheetData();

            int rowCount = grid.Rows.Count;
            int colCount = grid.Columns.Count;

            for (int r = 0; r < rowCount; r++)
            {
                List <object> values = new List <object>();
                for (int c = 0; c < colCount; c++)
                {
                    values.Add(grid[c, r].Value);
                }

                ExcelRowData rowData = new ExcelRowData(1, r + 1, values.ToArray());
                data.Rows.Add(rowData);
            }

            ExcelBorderData borderData = new ExcelBorderData(1, 1, rowCount, colCount);

            borderData.Borders.Add(new ExcelBorderItem(ExcelBordersIndex.xlAround, ExcelBorderWeight.xlThick, ExcelLineStyle.xlDouble));
            borderData.Borders.Add(new ExcelBorderItem(ExcelBordersIndex.xlInside, ExcelBorderWeight.xlHairline, ExcelLineStyle.xlContinuous));
            data.Borders.Add(borderData);

            return(data);
        }
예제 #3
0
 void insertData(ExcelSheetData data)
 {
     foreach (ExcelRowData row in data.Rows)
     {
         insertRowData(row);
     }
     foreach (ExcelBorderData border in data.Borders)
     {
         insertBorderData(border);
     }
     foreach (ExcelFormatData format in data.Formats)
     {
         insertFormatData(format);
     }
     foreach (ExcelCellData cell in data.Cells)
     {
         insertCellData(cell);
     }
     foreach (ExcelFormula formula in data.Formulas)
     {
         insertFormula(formula);
     }
 }
예제 #4
0
 public void InsertSheetData(ExcelSheetData data)
 {
     insertData(data);
 }