We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Repeated save causes empty spreadsheet?

Here's a strange problem. We have an application that runs an automated test system. Test parameters are read from the spreadsheet, results are written to the spreadsheet. We perform multiple tests in a run, saving the workbook to the same file at the end of each test (think committing a record to a database). We noticed that after the 2nd test, the spreadsheet becomes empty. There's one worksheet "Sheet1" which has no data at all in it. Should we re-read the spreadsheet after saving it to re-load the object? The object in memory seems to be OK as we continue to grab data from it without problems, we get no exceptions back from the calls to PutValue when we write data from the 2nd test.

Hi,

Yes, you have to re-open the spreadsheet and save it as repeatedly if you want to save multiple copies of a spreadsheet. For your info, the Workbook object with all other related objects, data would be null. I think you may try some loop(s) and write your code in it.

Thank you.

Thank you.

OK, thanks. I'll whip up a test program to see what I need to do. I'm actually not trying to save multiple copies, rather I want to save the same one multiple times - for example, if the automation suite crashes in the middle of the run I don't want to lose my results up to that point. Perhaps I wasn't totally clear on that. Anyway, I now have ideas to go on and I should be able to figure out how to handle this. Thanks again!

Test completed. After performing a save operation, the loaded worksheet object reverts to it's default state: a single worksheet called "Sheet1", with no data whatsoever. I'll be able to work around this by reloading the file after the save, but that's still annoying.

Consider this a change request: Preserve the spreadsheet objects so the user doesn't have to reload anything after doing a save. Excel functions that way, and it's a lot more efficient if you're storing data in a spreadsheet and don't have to re-load the workbook and restore all the objects every single time you save to a file.

-- Carl