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 May 21, 2019 5:28 am

Good day!

I was having an issue about converting a worksheet. I have 3 worksheets, the first worksheet has a value but sheet 2 and sheet 3 has no value or no data entered.
I was about to save a worksheet to image file and throws a object reference error in c#. Upon investigating the issue I have found out that the code could not able to convert a worksheet that has no value. The question is how will I know if the worksheet has no value? this is to avoid converting the blank worksheets.

Here's the example code that I use to convert a Image. The code is working perfectly but I haven't find any code that can detect that the worksheet is empty or no value.

Example code:

foreach (Worksheet sheetss in workbook.Worksheets)
{
Worksheet sheet = workbook.Worksheets[iRow];
sheet.SaveToImage(downloadPath + "_" + replacedFilename + "_" + iRow + ".jpg");

iRow++;
}


Thank you!
Attachments
New Excel File.rar
(6.46 KiB) Downloaded 179 times

tcballelos
 
Posts: 36
Joined: Wed Nov 28, 2018 5:35 am

Tue May 21, 2019 8:27 am

Hello,

Thank you for contacting.
Please use sheet.IsEmpty to judge the worksheet is empty or not, and you can refer to the following code snippet to get rid of the object reference error. If there is any other question, welcome to write back.
Code: Select all
......
Worksheet sheet = workbook.Worksheets[iRow];
if (!sheet.IsEmpty)
{
    sheet.SaveToImage(downloadPath + "_" + replacedFilename + "_" + iRow + ".jpg");
}
......

Sincerely,
Lisa
E-iceblue support team
User avatar

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

Wed May 22, 2019 6:08 am

Good day!

I have a follow up question, upon converting a excel file to image having a hundreds of columns the problem encountered is that It shrinks and turns into one page. but when converting it to excel to pdf it divides up to many pages. I have attached a file that is converted to the excel file and the screenshot of shrink excel data.

This is the example code:

//Creating .xlsx file to Image
foreach (Worksheet sheetss in workbook.Worksheets)
{
Worksheet sheet = workbook.Worksheets[iRow];
sheet.SaveToImage(downloadPath + "_" + replacedFilename + "_" + iRow + ".jpg");

iRow++;
}
Attachments
PROD_Documents.rar
(389.23 KiB) Downloaded 206 times

tcballelos
 
Posts: 36
Joined: Wed Nov 28, 2018 5:35 am

Wed May 22, 2019 9:12 am

Hello,

Thanks for your inquiry.
Kindly note there are parameters “int firstRow, int firstColumn, int lastRow, int lastColumn” which are designed practically for selecting a data range in one of the overloaded methods of SaveToImage(). You can refer to the below code snippet to specify a data range to split into multiple images. If there is any question, welcome to write back.
Code: Select all
......
sheet.SaveToImage(SavePath,  1, 1, 50, 8);
.......

Sincerely,
Lisa
E-iceblue support team
User avatar

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

Mon May 27, 2019 2:30 am

Good day!

I just want to know what are the limitations of converting with excel? specially when converting excel to images?

1.) There was a problem of shrinking when the column is greater than 8
2.) There was a problem when converting a excel to image when the column is only one it strecthed

Questions:
1.) what are the limitations of converting with excel?
2.) Can it convert a excel file having a freeze pane with many columns?
3.) Can it convert a excel file having many rows having only a image not a value?
4.) What are the excel values can only converted to images?
5.) Is spire.xls can be considered to convert many columns and multiple image just like spire.pdf functions, because with spire.pdf, it automatically split a excel file if the excel file has a multiple number of rows.

Thank you!

tcballelos
 
Posts: 36
Joined: Wed Nov 28, 2018 5:35 am

Mon May 27, 2019 7:31 am

Hello,

Thanks for your feedback.
First, about your problems, sorry that I didn’t quite understand what you mean by "the column is only one it strecthed", and after an initial test with the latest Spire.XLS Pack(Hotfix) Version:9.5.11, I didn't reproduce the shrinking problem. To help us further look into your issue, please provide your testing file, full testing code as well as more information of your problems. You could send them to us via email (support@e-iceblue.com).
Second, as for your questions, Please kindly note that our Spire.XLS is based on MS Excel and supports main and common features as MS Excel.
1.) Only our free version is limited to 5 sheets per workbook and 200 rows per sheet. This limitation is enforced during reading or writing XLS or PDF files. and when converting Excel files to PDF files, you can only get the first 3 pages of PDF file. Our paid version has no any limitations.
2.) Our Spire.XLS supports converting an excel file having a freeze pane with many columns.
3.) Our Spire.XLS supports converting an excel file having many rows having only an image not a value.
4.) Sorry I didn’t quite sure your requirement. Could you please share us with the details about it?
5.) As above mentioned, our Spire.XLS is based on MS Excel, it also can't split into multiple images automatically if you save to image by MS Excel. Thus, sorry that our Spire.XLS can't be considered to convert many columns and multiple images automatically. You need to call the overload method ( sheet.SaveToImage(SavePath, 1, 1, 50, 10) ) to split it.
If there is any question, please provide your sample files to help us further investigate it.

Sincerely,
Lisa
E-iceblue support team
User avatar

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

Tue Jun 11, 2019 2:46 am

Hello,

Greetings from E-iceblue.
Could you please let us know how are the issues going? Thanks in advance for your valuable 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