My application requires that I write workbooks to a database rather than the filesystem. When I read the workbook from the database, it has some significant differences from the workbook I actually generated. The workbook has a number of worksheets, each of which contains a line chart, a bar chart, or a column chart. I've noticed the following issues with the charts:
1) Colors are different from what I specified
2) Fonts are different from what I specified
3) All datapoint labels are missing
In attempting to isolate the problem, I tried converting the workbook to a byte array and then streaming it to the browser. The results in a workbook with the issues listed above. My code for doing this is:
// Stream file to browser.
System.IO.MemoryStream ms = workbook.SaveToStream();
response.AddHeader("Content-Disposition", "inline; filename=" + fileName);
response.ContentType = "application/octet-stream";
When I output directly to the browser using the Workbook.Save(..) method, the workbook is fine. Here's the code I use for this:
// Output to browser.
XlsSaveOptions saveOptions = new XlsSaveOptions();
saveOptions.SaveFormat = SaveFormat.Xlsx;
workbook.Save(response, fileName, ContentDisposition.Attachment, saveOptions);
It appears that the database is not what's causing the problem. Rather, it seems to have to do with my use of the Workbook.SaveToStream() method. Any idea what the problem could be? Thanks for your help.