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.

Tue Mar 12, 2019 6:26 pm

Hi all,
I am new in the use of Sprie.XLS and I was testing the ToImage function to export a range of cells as an image.
The white borders around the image always appear or only in this trial version?

Thanks,
Ricardo.

rbossio
 
Posts: 1
Joined: Tue Mar 12, 2019 4:59 pm

Wed Mar 13, 2019 3:03 am

Hello,

Thanks for your interests in our Spire.XLS.
Before saving to an image, you could try to set the margins of page to "0" like the following sample code. If there is still any issue after trying. Please provide your input Excel file as well as your generated image to help us further look into it. You could send them to us via email (support@e-iceblue.com).
Code: Select all
Workbook workbook = new Workbook();
workbook.LoadFromFile(@"test.xlsx");
Worksheet sheet = workbook.Worksheets[0];
//set the margins of page to "0"
sheet.PageSetup.LeftMargin = 0;
sheet.PageSetup.RightMargin = 0;
sheet.PageSetup.BottomMargin = 0;
sheet.PageSetup.TopMargin = 0;
//save the first 3 rows and first 3 columns to an image
sheet.ToImage(1, 1, 3, 3).Save("SheetToImage.jpg");

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1261
Joined: Wed Apr 25, 2018 3:20 am

Mon Mar 18, 2019 9:58 am

Hello,

Greetings from E-icbelue.
Did my code help you? Thanks in advance for your feedback and time.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1261
Joined: Wed Apr 25, 2018 3:20 am

Return to Spire.XLS