I'm using aspose.cells to add an image to the background of each page of an excel document to represent a watermark of sorts. The problem I seem to be having is that when I save the document the mime type is not set properly. The code I am using is below:
When I then save the file to my desktop and open with excel it tells me the file is not an excel file. The mimetype appears to be application/octet-stream??
I am not sure about your code (especially regarding saving
the excel file), I think you may save the file directly to disk (e.g
workbook.Save(“f:\test\outputfile.xls”, FileFormatType.Excel2003)
or use my updated code. I have tried it and it works fine.
Sample code: Workbook workbook = new Workbook(); workbook.Open(“f:\test\MyFile.xls”); FileStream watermarkStream = File.OpenRead(“f:\test\school.jpg”); byte[] imageData = new byte[watermarkStream.Length]; watermarkStream.Read(imageData, 0, imageData.Length); for (int i = 0; i < workbook.Worksheets.Count; i++) {
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.