Beispiel #1
0
        public static int QuickWrite(ExcelSheet excelSheet, string filePath, ExcelVersions version = ExcelVersions.Xls)
        {
            using (FileStream fs = File.Open(filePath, FileMode.OpenOrCreate, FileAccess.ReadWrite))
            {
                IWorkbook workbook = OpenWrite(version);
                ISheet    sheet    = workbook.CreateSheet(string.IsNullOrEmpty(excelSheet.Name) ? "sheet1" : excelSheet.Name);

                for (int i = 0; i < excelSheet.Rows.Count; i++)
                {
                    IRow row = sheet.CreateRow(i);

                    ExcelRow excelRow = excelSheet.Rows[i];

                    for (int j = 0; j < excelRow.Cells.Count; j++)
                    {
                        ExcelCell excelCell = excelRow.GetCell(j);

                        ICell cell = CreateCell(row, j, excelCell);
                    }
                }

                workbook.Write(fs);
                fs.Close();
                return(DotNETCode.SUCCESS);
            }
        }
    void DrawRow(ExcelRow row, Predicate <ExcelCell> drawCellFunc)
    {
        bool dirty;

        for (int i = 0; i < row.count; i++)
        {
            dirty = drawCellFunc(row.GetCell(i));
            if (!dirty && row.isDirty == false)
            {
                row.isDirty = true;
            }
        }
    }