I am trying to open an .xlsx file using Npoi but it keeps crashing with the following error:
1 is not a supported code page.
Parameter name: codepage
My code is very simple:
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Excel Workbook|*.xlsx";
DialogResult dr = ofd.ShowDialog();
if (dr == DialogResult.OK)
{
XSSFWorkbook myWorkbook;
FileStream fs = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read);
using (fs)
{
myWorkbook = new XSSFWorkbook(ofd.FileName);
}
}
The error happens while trying to create the workbook. I tried also using the stream, such as:
myWorkbook = new XSSFWorkbook(fs);
Does anyone know what is wrong? I can't find a proper example on the net for dealing with .xlsx files. I am suing the latest build (2.0.1).
Thanks.
I was able to open the file successfully using EPPlus, another Excel library. I still use NPOI for .xls files but for .xlsx I think it has a long way to go.