Beispiel #1
0
        public void WriteRange(object[][] data, string startCell)
        {
            int        startRowIndex  = worksheet.GetRowIndex(startCell);
            int        startCellIndex = worksheet.GetRowIndex(startCell);
            List <Row> newRows        = new List <Row>();

            for (int i = 0; i < data.Length; i++)
            {
                int rowIndex = startRowIndex + 1;
                Row row      = worksheet.GetRow(rowIndex);
                if (row == null)
                {
                    row = new Row()
                    {
                        RowIndex = (uint)rowIndex
                    };
                    newRows.Add(row);
                }
                for (int j = 0; j < data[i].Length; j++)
                {
                    int    cellIndex   = startCellIndex + j;
                    string cellAddress = SpreadsheetExtender.ToCellAddress(rowIndex, cellIndex);
                    Cell   resultCell  = row.GetCell(cellAddress);
                    if (resultCell == null)
                    {
                        resultCell = row.CreateCell(cellAddress);
                    }
                    resultCell.SetCellText(data[i][j]);
                    int styleIndex = SpreadsheetExtender.GetCellStyleIndex(styleSheet, data[i][j]);
                    resultCell.SetCellStyle(styleIndex);
                }
                sheetData.Append(newRows.ToArray());
            }
        }