0

I am having a linux machine and want system drawing to convert a excel table to image for Free.

Here is my code

using GrapeCity.Documents.Excel;
using System;
using System.Drawing;
using System.IO;

class Program
{
    static void Main()
    {
        //Create a new workbook
        var workbook = new GrapeCity.Documents.Excel.Workbook();
        Console.WriteLine("Working...");
        FileStream fileStream = new FileStream("Test121.xlsx", FileMode.Open);
        
        //Open a xlsx file 
        workbook.Open(fileStream);
        IWorksheet worksheet = workbook.Worksheets[0];
        
        //Export the worksheet to image 
        worksheet.ToImage("Test121.png");
        Console.WriteLine("Done!!");
    }
}

but this gives a warning at top of image that it is unlicensed

I also could not use Spire.XLS as my excel file could have more than 200 rows.

btw i am using C#.Net on my ubuntu 20.04 LTS

1hiv2m
  • 23
  • 8
  • saving as image's result can vary from libraries, and maybe microsoft interop is best for you. https://stackoverflow.com/a/1288110/1518100 – Lei Yang Jan 24 '22 at 05:54
  • will it work in linux – 1hiv2m Jan 24 '22 at 06:43
  • i'm afraid not. after reading your question again, i noticed you want to save specific 2d table to image, instead of arbitrary excel range. so you can search for 'C# reporting' tools, for example https://github.com/FastReports/FastReport – Lei Yang Jan 24 '22 at 06:54
  • @LeiYang i wanted to convert my excel sheet content to image but in this code i have to purchase GC excel. But i wanted a free conversion ie. from system. – 1hiv2m Jan 24 '22 at 07:02
  • the library FastReport is open source, let alone free. – Lei Yang Jan 24 '22 at 07:04
  • i don't want to depend my app on any api. it should be independent and could run on any platform – 1hiv2m Jan 24 '22 at 09:46
  • how do you define an **api**? can you give an example that is very useful but is not an api? – Lei Yang Jan 24 '22 at 09:48
  • **api** like `GrapeCity.Documents.Excel` is an external api added to my project – 1hiv2m Jan 24 '22 at 09:56
  • `GrapeCity.Documents.Excel` is what you don't want. please give an example that is both useful and you don't need add to your project. – Lei Yang Jan 24 '22 at 09:58
  • Do you want to draw a range exactly as it would appear in excel? Then you'll have to use excel (probably). Otherwise you can use the openxml package to read a spreadsheet file, locate the values in a range, then do whatever you want with that data. (https://learn.microsoft.com/en-us/office/open-xml/how-to-parse-and-read-a-large-spreadsheet) – Jeremy Lakeman Jan 24 '22 at 10:23
  • @JeremyLakeman Yes i want to draw a range, but with **openxml** how to convert it to image – 1hiv2m Jan 24 '22 at 12:28
  • @JeremyLakeman can you answer please – 1hiv2m Feb 03 '22 at 12:35
  • How to take data from openxml and render an image. That is out of scope for an SO answer. Just because excel makes it look easy, doesn't mean there is any easy way without using excel. Unless there's a library which already exists, but which you don't want to pay for. But you already ruled that out. – Jeremy Lakeman Feb 03 '22 at 23:52

0 Answers0