This project is read-only.

NPOI makes a mess of my .XLSX file when writing to existing file

Jun 23, 2013 at 9:54 PM
Hi folks,

When I wrtie to an .XLS file there is no problem, it works correct. But when I write to a .XLSX file the file is messed up. Mu code is ±

private IWorkbook wb;

// Class and code
                FileStream file = new FileStream(bestand, FileMode.Open, FileAccess.Read);

                string ext = Path.GetExtension(bestand).ToLower();

                if (ext == ".xls")
                {
                    wb = new HSSFWorkbook(file);
                }
                else if (ext == ".xlsx")
                    wb = new XSSFWorkbook(file);

                ISheet ws = wb.GetSheet(Maanden[maand-1]); // The month sheet

                ws.GetRow(colum).GetCell(rij++).SetCellValue(huidigedatum);
                                ws.GetRow(colum).GetCell(rij++).SetCellValue(Datarow["Factuurnummer"].ToString());
                                ws.GetRow(colum).GetCell(rij++).SetCellValue(Datarow["Omschrijving"].ToString());

                                ws.GetRow(colum++).GetCell(tbBank-1).SetCellValue((double)totaal);
It this the way to write? to an .XLSX file.

Regards rinaldo