Can I use Workbook object as a datasource for WebGrid component?

I have a fair amount of code against loading a template file into a workbook object and manipulating the data (this was previously being exported as a xls file). I would now, instead, like to load that object into a webgrid, is this possible? I’m having a bit of trouble figuring out just exactly how I would do this…

Hi,

Thanks for your posting and using Aspose.Cells for GridWeb.

Yes, it is possible. Please see the following code how to achieve your goals.

Please also read the comments.

C#



Workbook workbook = new Workbook();


//Do your work on your workbook object and then

//finally save it into memory stream



MemoryStream ms = new MemoryStream();

workbook.Save(ms, SaveFormat.Excel97To2003);


ms.Position = 0;


//Import your save memory stream into GridWeb.

GridWeb1.WebWorksheets.ImportExcelFile(ms);



Ahh… Perfect. Thank you. One other quick question though, if I just use a WebGrid and populate the WebWorkSheets manually my formulas are right aligned (which is what I would expect since they are calculations). However, when I use the method above the formulas are left aligned… any ideas on why this might be and or how to fix it?

Hi,

Please download and use the latest version:
Aspose.Cells
for GridDesktop v2.7.4.2001

and let us know your feedback.

If the problem still occurs, then please provide us simpler runnable code to replicate the problem.

If you are using some input files then please also provide.

Please illustrate your problems with screenshot and highlight the intended areas with red circles for sorting out issue quickly.

Actually I’m using the Aspose.Cells.GridWeb.dll, do you have a link to an updated version of that one? I’m running the 2.7.4.2000 build at the moment.

Hi,

Thanks for letting me know about the wrong link.

Please get the latest version of GridWeb dll from this link:
Aspose.Cells
for GridWeb v2.7.4.2001