How to create a Chart on a WebWorksheet

We have been trying to create a chart on a webworksheet but with no success. We managed to do this on a normal Workbook - Worksheet but since we use a web platform for our applications we need this to work on the WebGrid for reports.


Regards,

Thomas

Hi,

We have supported to import chart and shape images from excel files in Aspose.Cells.GridWeb v2.6.0.2002.

Please update the dll and acwmain.js files.

Hi,


thanks for your reply. We have the latest version of Aspose.Cells.

What we would like to do is either:
  1. Generate a Chart from the code behind and put it onto a Webgrid next to the data.
  2. Or even better have a Chart generated dynamically from existing data on the Webgrid.
Either or it would work for us.

Kind Regards,

Thomas

Hi,

You are right, both should work fine.

Did you see our offlines demos of GridWeb? You can run them in Visual Studio 2005 or 2008 or 2010, whatever is available to you.

I will highly recommend you to use our offline demos, it will help you increase your knowledge and skill of Aspose.Cells gridweb manifold.

Please visit this link and download: Aspose.Cells.GridWeb C# Demos

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

Please do readme.txt file before running the demos.

Hi,


yes we have gone through both the Aspose.Cells and Aspose.Cells.GridWeb offline demos but unfortunately we could not find what we are looking for.

Namely, in the GridWeb demos we could not find any mention of Charts being added to it.

Further help (maybe with a short sample) would be greatly appreciated.

Kind Regards,

Thomas

Any updates on the above please?


Kind Regards,

Thomas

Hi,

Sorry for late update. We will look into this issue and provide you a code example. We need more time and we will get back to you asap.

Thanks for your patience.

Thanks!


Thomas

Hi,

Please see the code below and the sample. It first creates a chart using Aspose.Cells for .NET then it imports the output excel file into GridWeb using Aspose.Cells for GridWeb

Please see the screenshot. For your more help, I have attached the complete project.

C#


//Create a workbook with a chart using Aspose.Cells
//and then import it into GridWeb using Aspose.Cells.GridWeb
Workbook workbook = new Workbook();

//Obtaining the reference of the newly added worksheet by passing its sheet index
Aspose.Cells.Worksheet worksheet = workbook.Worksheets[0];

//Adding a sample value to “A1” cell
worksheet.Cells[“A1”].PutValue(50);

//Adding a sample value to “A2” cell
worksheet.Cells[“A2”].PutValue(100);

//Adding a sample value to “A3” cell
worksheet.Cells[“A3”].PutValue(150);

//Adding a sample value to “B1” cell
worksheet.Cells[“B1”].PutValue(4);

//Adding a sample value to “B2” cell
worksheet.Cells[“B2”].PutValue(20);

//Adding a sample value to “B3” cell
worksheet.Cells[“B3”].PutValue(50);

//Adding a chart to the worksheet
int chartIndex = worksheet.Charts.Add(Aspose.Cells.Charts.ChartType.Column3D, 5, 0, 15, 5);

//Accessing the instance of the newly added chart
Aspose.Cells.Charts.Chart chart = worksheet.Charts[chartIndex];

//Adding SeriesCollection (chart data source) to the chart ranging from “A1” cell to “B3”
chart.NSeries.Add(“A1:B3”, true);

//Save the workbook into memory stream
MemoryStream ms = new MemoryStream();
workbook.Save(ms, SaveFormat.Xlsx);
ms.Position = 0;

//Import the excel file with chart into gridweb
GridWeb1.WebWorksheets.ImportExcelFile(ms);
Screenshot:

Thank you for your help, unfortunately it seems that it is still not working.


I do not know what we are doing wrong.

I am attaching a copy of our solution which was created using Visual Studio 2008. We used the code given in the above example but unfortunately the graph did not show when we ran the app.

Kind Regards,

Thomas

PS. I also tried running your sample solution attached but with the same result. (See attached screen shot).

Hi,

Thanks for your feedback. We will look into your project soon and update you asap.

Hi,


I can see that your project is still using Aspose.Cells.GridWeb v2.6.0.2000. Please use our latest version/fix that Shakeel Faiz attached in his previous post e.g v2.6.0.2002:

Aspose.Cells.GridWeb v2.6.0.2002.

Please don’t forget to update the dll and acwmain.js files in the zipped archive too.

Thank you.

Hi,

Please copy “acw_client” folder with files (according to Aspose.Cells.GridWeb v2.6.0.2002) into your project, and add these configurations into appSettings section in your web.config:


<add key=“aspose.cells.gridweb.acw_client_path” value=“~/acw_client/”/>

<add key=“aspose.cells.gridweb.force_script_path” value=“true”/>

<add key=“aspose.cells.gridweb.forcepath” value=“true”/>


Your project works fine now.