Convert excel file to jpg in c

0 votes

I am trying to use Spire dll to convert an excel file to jpg.

The  xlsm file:

enter image description here

I use this code to convert it to jpg :

    Workbook workbook = new Workbook();
    workbook.LoadFromFile(@"D:\a.xlsm");
    Worksheet sheet = workbook.Worksheets[1];
    sheet.SaveToImage("exceltoimage.jpg");
    System.Diagnostics.Process.Start("exceltoimage.jpg");

But the output is like this some of the cells can't be converted why do I mean (#name)?

enter image description here

I have this warning on my page :

enter image description here

Dec 26, 2022 in Others by Kithuzzz
• 38,000 points
1,202 views

1 answer to this question.

0 votes

You can use Aspose :

http://www.aspose.com/community/files/51/.net-components/aspose.cells-for-.net/category1129.aspx

For example :

http://www.aspose.com/docs/display/cellsnet/Converting+Worksheet+to+Image

Sample code :

 Workbook workbook = new Workbook(@"D:\a.xlsm");
            //Get the first worksheet.
            Worksheet sheet = workbook.Worksheets[12];

            //Define ImageOrPrintOptions
            ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
            //Specify the image format
            imgOptions.ImageFormat = System.Drawing.Imaging.ImageFormat.Jpeg;
            //Only one page for the whole sheet would be rendered
            imgOptions.OnePagePerSheet = true;

            //Render the sheet with respect to specified image/print options
            SheetRender sr = new SheetRender(sheet, imgOptions);
            //Render the image for the sheet
            Bitmap bitmap = sr.ToImage(0);

            //Save the image file specifying its image format.
            bitmap.Save(@"d:\SheetImage.jpg");
answered Dec 27, 2022 by narikkadan
• 63,640 points

Related Questions In Others

0 votes
1 answer

Convert table in a jpg image to excel using python

I believe you must execute OCR (optical ...READ MORE

answered Oct 16, 2022 in Others by narikkadan
• 63,640 points
2,264 views
0 votes
1 answer

Convert a single png file to jpg in vba

Try this code: Sub ConveretPNGToJpg() ...READ MORE

answered Oct 16, 2022 in Others by narikkadan
• 63,640 points
1,557 views
0 votes
1 answer

How to open an Excel file in C#?

You must have Microsoft Visual Studio Tools ...READ MORE

answered Nov 13, 2022 in Others by narikkadan
• 63,640 points
1,247 views
0 votes
1 answer

Convert JSON file to Excel File

Hi To convert a file, Set options and ...READ MORE

answered Feb 16, 2022 in Others by Edureka
• 13,690 points
1,271 views
0 votes
1 answer

Generate a flat list of all excel cell formulas

Hello, you'll have to follow certain steps ...READ MORE

answered Feb 18, 2022 in Others by gaurav
• 23,260 points
543 views
0 votes
1 answer

How to Freeze Top Row and Apply Filter in Excel Automation with C#

Try this: // Fix first row workSheet.Activate(); workSheet.Application.ActiveWindow.SplitRow = 1; workSheet.Application.ActiveWindow.FreezePanes ...READ MORE

answered Oct 22, 2022 in Others by narikkadan
• 63,640 points
2,629 views
0 votes
1 answer

Retrieve epay.info Balance with VBA and Excel

This code should log you in, provided ...READ MORE

answered Sep 5, 2018 in Blockchain by digger
• 26,740 points
1,188 views
0 votes
1 answer

How to load file to Excel Power query from SFTP site

Currently, I don't think there is a ...READ MORE

answered Dec 3, 2018 in Power BI by Upasana
• 8,620 points
3,642 views
0 votes
1 answer

Convert image (jpg) to base64 in Excel VBA?

Heres a function. Can't remember where I ...READ MORE

answered Sep 27, 2022 in Others by narikkadan
• 63,640 points
3,012 views
0 votes
1 answer

How to convert PDF to Excel in C#?

Solutions a) xodo makes a free online conversion from PDF ...READ MORE

answered Oct 1, 2022 in Others by narikkadan
• 63,640 points
978 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP