SARATH
SARATH

Reputation: 49

style class in c#

I am opening an excel and displaying it in grid using Interop.Excel

I want to show the data in the grid as in excel. I mean same styles should be applied. I am using datatable for reading data from excel and bingding it to grid.

I have tried the following. While reading the cell data, I am reading the style of the cell into Style class and tried to apply in the grid. but while running it was throwing exception cannot convert an object Excel.Style to WebControls.Style. Is there any way to achieve it?

THanks in advance......

Upvotes: 0

Views: 355

Answers (1)

Bradley Smith
Bradley Smith

Reputation: 13601

Excel.Style is a COM type, and does not inherit any .NET classes/interfaces for web applications. There is also no explicit conversion to/from WebControls.Style. You will have to write your own method to populate a new style object from an Excel style.

You will not be able to completely reproduce the style, either; as WebControls.Style only supports a limited subset of the properties in Excel.Style. You will have to go through the properties of the web control style class and, on an individual basis, work out how to best map to the equivalent property in the Excel style.

Upvotes: 1

Related Questions