NPOI Generate Excel with Date Format

Jika kita ingin memasukkan object DateTime ke dalam cell menggunakan NPOI, perlu ada penanganan khusus. [code language=”csharp”] XSSFCellStyle styleDate = (XSSFCellStyle)workbook.CreateCellStyle(); styleDate.DataFormat = workbook.CreateDataFormat().GetFormat("yyyy-mm-dd HH:mm"); XSSFCell cell = (XSSFCell)row.CreateCell(colIndex++); cell.SetCellValue(single.Timestamp); cell.CellStyle = styleDate; [/code] http://stackoverflow.com/questions/3425931/npoi-excel-number-format-not-showing-in-excel-sheet-in-asp-net

NPOI Read Excel File

Contoh kode menggunakan lib NPOI untuk membaca file excel (xlsx) [code language=”csharp”] //kamus List<ManufacturerFormStub> ret = new List<ManufacturerFormStub>(); string imagePath = null; //algoritma string currentFilePathInServer = HttpContext.Current.Server.MapPath(FilePath); XSSFWorkbook book; using (FileStream file = new FileStream(currentFilePathInServer, FileMode.Open, FileAccess.Read)) { book = new XSSFWorkbook(file); } XSSFSheet sheet = (XSSFSheet)book.GetSheet("manufacturer"); for (int row = 1; row < sheet.LastRowNum;…

ASP MVC Create/Export Excel using NPOI

Pemrosesan excel menggunakan Excel.Interop di ASP sepertinya bermasalah. 1. Perlu meng-install excel di server 2. Ada potensi error “Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 8000401a The server process could not be started because the configured identity is incorrect. Check the username and password. (Exception from…

ASP.NET Interop.Excel Import Failed Not Enough Memory

Sewaktu men-deploy aplikasi di server CSS Pertamina, muncul masalah di fitur export excel. Microsoft Office Excel cannot open or save any more documents because there is not enough available memory or disk space. Ada solusi dari web ini yang berhasil. I know this is an old thread but I wanted to share what worked for…