Quantcast
Channel: NPOI
Viewing all articles
Browse latest Browse all 1621

New Post: XLS file created from template doesn't save correctly - any ideas?

$
0
0
Hi,

Using NPOI, I'm successfully creating a spreadsheet from an XLT template, but when I subsequently open the spreadsheet in MS Excel it still thinks it's an XLT template.

I've checked through the online documentation and my code appears to be correct - does anyone have any ideas on what I'm doing wrong please?

Steps to re-produce are as follows:

1) Create XLT template (using MS Excel)
2) Use the following code to create a spreadsheet from the template
const string templatePath = @"C:\Temp\Template.xlt";
const string spreadsheetPath = @"C:\Temp\Spreadsheet.xls";
HSSFWorkbook workbook;
using (var fs = new FileStream(templatePath, FileMode.Open))
{
                workbook = new HSSFWorkbook(fs);
}
using (var fs = new FileStream(spreadsheetPath, FileMode.Create))
{
                workbook.Write(fs);
}
3) Open the file in MS Excel and click File > Save As

At this point MS Excel thinks you are trying to save an XLT template file (it automatically selects to save as type xlt file).

If anyone has any ideas on what I might be doing wrong, or if this is a genuine bug, that would really helpful!

If it has any bearing, I'm using NPOI v2.0.1.0 and Excel 2003.

Thanks.

Viewing all articles
Browse latest Browse all 1621

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>