Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Fri Apr 15, 2022 8:12 pm

Hi,

I am using ToImage for an existing excel file and the background colors are not saving to the image. How can I capture the existing background color in my image?

Here is my code:

string screenshot1 = "C:/TEMP/screenshot1.png";
string screenshot2 = "C:/TEMP/screenshot2.png";


Workbook workbook = new Workbook();
workbook.LoadFromFile(@"C:\TEMP\DailyShipmentsRQ_DoNotUseee.xlsx");


Worksheet sheet = workbook.Worksheets[0];

sheet.ToImage(1,1,35,20).Save(screenshot2, ImageFormat.Png);


Worksheet sheet2 = workbook.Worksheets[2];
sheet2.ToImage(1, 1, 16,7).Save(screenshot1, ImageFormat.Png);


string screenshot1 = "C:/TEMP/screenshot1.png";
string screenshot2 = "C:/TEMP/screenshot2.png";


Workbook workbook = new Workbook();
workbook.LoadFromFile(@"C:\TEMP\DailyShipmentsRQ_DoNotUseee.xlsx");


Worksheet sheet = workbook.Worksheets[0];

sheet.ToImage(1,1,35,20).Save(screenshot2, ImageFormat.Png);


Worksheet sheet2 = workbook.Worksheets[2];
sheet2.ToImage(1, 1, 16,7).Save(screenshot1, ImageFormat.Png);

Thanks,
Attachments
worksheet3.PNG
worksheet3.PNG (8.84 KiB) Viewed 451 times
screenshot1.png
screenshot1.png (6.36 KiB) Viewed 451 times

reginaqv
 
Posts: 1
Joined: Fri Apr 15, 2022 4:02 pm

Mon Apr 18, 2022 2:13 am

Hello,

Thanks for your inquiry.
I simulated an excel file and tested the code you provided, but didn't reproduce the issue you mentioned. The version I used is the latest version(Spire.XLS Pack(Hotfix) Version:12.4.1). If you were not using the latest version, please first give it a try. If the issue still exists after trying, please provide the following information for further investigation. You could attach them here or send them to us via email (support@e-iceblue.com). Thanks in advance.
1) Your sample Excel file.
2) Your test environment, such as OS info (E.g. Windows 7, 64-bit) and region setting (E.g. China, Chinese).
3) Your application type, such as Console app (. Net Framework 4.5).

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1643
Joined: Wed Apr 07, 2021 2:50 am

Return to Spire.XLS