Charts output in HTML- CSV formats don't display

I’m using SmartMarkers to fill in Excel file templates with data to produce a chart. This works great for Excel formats, but when I switch Aspose.Cells to output using HTML, CSV, or TSV, I get strange results.

I understand that neither CSV nor TSV will support images, and thus I understand that my chart will not display, but I am surprised that I get absolutely no output at all. I think what may be happening is Aspose.Cells is only trying to output the first sheet of the workbook, which in my case is the chart sheet, so it just gives up. Is there any way to make it output the data from the 2nd sheet in these cases (or perhaps there is some other problem here)?

When I output in HTML mode, I also get strange results. The page is largely blank in my web browser except for a missing image icon. I can only assume that the image is intended to be the chart. The path to the chart image file in the HTML is invalid. Is there any way to get the image file for the chart out of Aspose.Cells? If not, is there a way to get the raw data like I asked for with CSV/TSV?

Thanks.

Hi,

Thank you for considering Aspose.

Well, as per your requirement regarding CSV, I think MS Excel does not provide this feature too. As Aspose.Cells provides the features and functionalities supported by MS Excel, so I am afraid this feature may not be supported by Aspose.Cells too.

For the issue regarding the HTML format, currently, we do not support to open the HTML format file directly in browser(using SaveType.OpenInBrowser).We will provide the support for this feature soon.

Thank You & Best Regards,

Thank you for your reply. I am slightly confused by your response, however. What is “this feature” you refer to that neither Excel nor Aspose.Cells provide? In Excel, if you try to save in CSV format and the workbook has multiple sheets, it will give you a message stating it is only going to save the active sheet. It suggests saving each sheet individually. Is there functionality in Aspose.Cells to do this automatically? Or perhaps to ignore “empty” sheets and output the first one with content that can be rendered in CSV? Looking briefly through the Aspose.Cells API, I was unable to find a function that could even set which sheet is the active sheet, much less do any of the other things I’m suggesting.

As for HTML, I am not opening in a browser via SaveType.OpenInBrowser. I did not know such a thing existed. I am simply calling WorkbookDesigner.Workbook.Save() with FileFormatType.Html as the second argument. I then open this file with a browser by hand.

With this extra info, can you help me get any closer to my goal? If not, is it something that may be supported in the future? Thank you very much for your time.

Hi,

Thank you for considering Aspose.

rmeador:

What is “this feature” you refer to that neither Excel nor Aspose.Cells provide?

Sorry for the confusion caused. From “this feature” I meant saving the chart in a CSV file.

rmeador:

In Excel, if you try to save in CSV format and the workbook has multiple sheets, it will give you a message stating it is only going to save the active sheet. It suggests saving each sheet individually. Is there functionality in Aspose.Cells to do this automatically? Or perhaps to ignore “empty” sheets and output the first one with content that can be rendered in CSV? Looking briefly through the Aspose.Cells API, I was unable to find a function that could even set which sheet is the active sheet, much less do any of the other things I’m suggesting.

Currently, Aspose.Cells will save the first worksheet in a workbook to a CSV file. We will see if we can support to save the active sheet as CSV file.(Just for you information, Workbook.Worksheets.ActiveSheetIndex property can be used to set the active worksheet index (zero based). But currently, its not supported to save a CSV file according to the active sheet and we will look into the feasibilty of supporting the feature of saving active sheet as CSV).

rmeador:

As for HTML, I am not opening in a browser via SaveType.OpenInBrowser. I did not know such a thing existed. I am simply calling WorkbookDesigner.Workbook.Save() with FileFormatType.Html as the second argument. I then open this file with a browser by hand.

Which version of Aspose.Cells are you using? The latest version supports saving different charts and other drawing objects in the generated HTML file (if saved to the hard drive). Please try the latest version from the following link:

Aspose.Cells for .NET (Latest Version)

If you still face any problem regarding the HTML file, please share your template excel file and we will look into it.

Thank You & Best Regards,

Hi,

First of all, please accept our apology from our side for creating some misconception about a feature which is indeed supported by Aspose.Cells component. I think Nausherwan may have missed but it happens sometimes you know. Hopefully, you won't take it serious :)

rmeador:
In Excel, if you try to save in CSV format and the workbook has multiple sheets, it will give you a message stating it is only going to save the active sheet. It suggests saving each sheet individually. Is there functionality in Aspose.Cells to do this automatically?

Aspose.Cells follows the MS Excel standards and yes, this functionality is supported by the component now. It is to be noted here, you need a valid license to implement this feature, see the following sample code. In the example, I have used an excel file which has multiple sheets in it and I activate my desired sheet before saving to csv format. Mind you if you don't activate a sheet, the first sheet would be considered as an active sheet to render to csv file format.

Sample code:

Aspose.Cells.License license = new Aspose.Cells.License();

license.SetLicense("f:\\Licenses\\Aspose.Cells.lic");

//Instantiate a new Workbook.

Workbook workbook = new Workbook();

workbook.Open("f:\\test\\myfile.xls");

//Set the second sheet as an active sheet.

workbook.Worksheets.ActiveSheetIndex = 1;

//Save the csv file.

workbook.Save("f:\\test\\csvfile.csv",FileFormatType.CSV);

Feel free to ask us any question if you need further help/clarifications.

Thank you.

I am still seeing problems with the HTML file after upgrading to 4.7.1.1, which is a release provided to me here. There are two problems, one of which may be a bug in your library, the other of which is probably a problem with my setup.

Firstly, as you can see in the attached image, the chart generated is missing data, missing labels, and has a black background. You can see what it’s supposed to look like in the excel2003.xls file attached to the other forum post I linked to above. I’ve attached the input template file. It was used to generate the HTML chart and the 2 files linked on that other post.

My second problem is the way producing HTML reports generates the chart image. It seems that it sends the image to C:\Windows\Temp automatically. Can I control this directory? Can I make it output to a stream instead of a file? Currently, I’m calling WorkbookDesigner.Workbook.Save() and providing it with a MemoryStream. The contents of the MemoryStream is sent back to our C++ application via COM without ever being written to disk. Ideally, I would like to be able to do the same thing with the chart image, or even better, have the chart image written into the HTML document itself (I’ve heard some browsers can embed images in that way, but I’m not sure if it is standardized). If the chart file must be written to disk, can I control where it is written and have it written with a unique file name that I can then retreive? I’d also like control over the path in the HTML output so that I can insert the appropriate URL to the file on a server so the HTML report will work anywhere, not just on the machine that generated it. I hope I’m not asking too much.

Thanks again.

Hi,

Thank you for considering Aspose.

We have found your mentioned issue regarding charts in HTML file after an initial test. We will look into it.

For your other issue regarding controlling the directory of images while saving as HTML, we will get get back to you soon.

Thank You & Best Regards,

Hi,

Please try the attached version. We have fixed the bug of exporting chart to html file.

And we add a new method i.e.., Workbook.Save(Stream stream, string title, string attachFilesDir) method to provide control where the chart is written.

Thank you.

I’ve tested using the version you provided. It does not seem to solve my problem. The chart image looks the same as it was before – it still has the black background.

The extra parameter to specify the attached files directory work correctly (in that it uses the directory), but it seems that it always forces the output to be in HTML format (which makes sense, since it doesn’t have a FileFormatType parameter). This won’t work with the rest of my application because it requires the ability to specify the file format when saving. Can you create an overload like this: Workbook.Save(Stream stream, FileFormatType fileFormatType, string attachFilesDir)?

Also, will it create the attachFilesDir if it does not exist? Unless you give me a way of saving the attached files to a Stream as well as the workbook (which I don’t think is possible, so don’t worry about it too much), I’m going to need to create a new directory for each invokation of my report so that the attached files don’t overwrite each other. It would simplify my code if I could depend on Workbook.Save() to create that directory for me.

One final thing… using attachFilesDir allows me to specify where on disk the files get written, but it also uses that same path in the tag in the HTML to embed the chart. Can you create a way to specify the path to the separately? I’d like to be able to have attachFilesDir be something like “d:\webroot\reports\report-1234” but have the in the HTML point at http://www.example.com/reports/report-1234/ChartChart.jpg. Perhaps adding another parameter to Workbook.Save() would allow that. I don’t want to try to tell you how to design your software, though.

Thank you very much for your help so far. I’m very impressed at how fast you’ve been handling these two issues I’ve discovered. Aspose definitely has the best customer service of any vendor I’ve ever worked with.

Hi,

Thanks for providing us further details.

Yes, we still find the chart's background color issue, we will figure it out soon.

And, yes, it will create a directory for attachFilesDir parameter, if it does not exist.

Moreover, we appreciate that you have given us some suggestions. We will analyze your suggestions and get back to you soon.

Thank you.

Hi,

Thank you for considering Aspose.

Please try the attached version. We have fixed the bug of exporting chart to html file. Also, we have added some new attributes i.e…, Workbook.AttachedFilesDirectory, Workbook.AttachedFilesUrlPrefix for saving html to stream to provide control of the attached file’s output directory and the Url prefix in the html file.

Please consult the following code sample:

string infn = path + "usage+report+10.xls";

string outfn = path + "usage+report+10_out.htm";

Workbook book = new Workbook();

book.Open(infn);

book.PageTitle = "the Page Title";

book.AttachedFilesDirectory = @"C:\test\Html\usereport10_Attached";

book.AttachedFilesUrlPrefix = @"http://www.example.com/usereport10_Attached/";

try{ File.Delete(outfn); } catch { }

FileStream fs = new FileStream(outfn, FileMode.CreateNew);

book.Save(fs, FileFormatType.Html);

fs.Close();

Thank You & Best Regards,

I did a quick test of the new package you sent me and it looks better, but there is still a bug. The black background is fixed, but the data is still not displaying in the chart. I’ve attached the output it generates now. I have not had a chance to test the new AttachedFilesDirectory or UrlPrefix attributes.

Hi,

Thank you for your feedback. We will further look into you mentioned issue regarding chart data and get back to you soon.

Thank You & Best Regards,

Hi,

Thank you for considering Aspose.

After further investigating your issue, we were unable to reproduce your mentioned problem. Please make sure to use WorkbookDesiger.Process() method before calling Chart2Image to populate the data using the smart markers. If you still face any problem, please create a sample console application and post it here, we will check it soon.

Thank You & Best Regards,