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

New Post: Unable to add new sheet to existing workbook

$
0
0
A thousand thanks, tonyqus. That worked like a charm.

For anyone else having the problem, here's how I fixed it:

//Check for existing workbook
FileStream fs = new FileStream(myExistingWorkbook.xlsx, FileMode.Open, FileAccess.ReadWrite);
IWorkBook workbook = new XSSFWorkbook(fs);
ISheet sheet1 = workbook.CreateSheet(newSheet);

//Code to populate new sheet content goes here

FileStream fs2 = new FileStream(mydocpath + @"\Productivity Report - " + fetch.ToString("MM-dd-yyyy") + ".xlsx", FileMode.Open, FileAccess.ReadWrite);
workbook.Write(fs2);
fs.Close();

Viewing all articles
Browse latest Browse all 1621

Trending Articles



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