none
What is VSTO architecture & design? Can it be used for export/Import of an excel file from asp.net web application? RRS feed

  • Question

  • In asp.net web application, I have implemented export to Excel feature, here for few of the row values I need to show text in excel with the font attributes i.e. Render HTML. If i use xls format then this works perfectly fine but when i use xlsx as the file type then HTML is not rendered while data is exported in excel, however the HTML tags are displayed as it is in exported excel file.
    To resolve this one of the suggestion i recieved is use VSTO architecture & design. But when i researched on this it looks irrelevant to me.. VSTO is for adding plugin in Microsoft Office tools and not for something to be worked in web application.
    Can someone please guide me with VSTO APIS for this functionality and also if there is any other option available to solve this?

    Friday, December 20, 2013 4:21 AM

Answers

All replies

  • Hi,

    VSTO is used to as a plugin hosting in Office application, it is a client plugin and need to install Office.

    I don't recommend you to use VSTO on server side.For more information, please refer to Office Solutions Development Overview.

    >> I have implemented export to Excel feature <<
    How do you export data to Excel in asp.net application?

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Saturday, December 21, 2013 5:32 AM
    Moderator

  • Thanks George.. regarding export to excel, I am not able to access the link. Will it export to xlsx format and also cell values with html font attributes  

    Saturday, December 21, 2013 9:19 AM
  • Hello CSharp_LOver007,

    The link provided above is irrelevant for you.

    VSTO is just a toolset for developing Office COM add-ins (application- and document-level add-ins). If you want to create/edit and etc. Office documents at runtime you need to use the Open XML SDK. Download it here . It allows creating and editing open xml format documents (for example - *.xslx) introduced with Office 2007. There is no need to have Office applications installed on the server in that case.

    But if you need to work with earlier binary file formats you have to use the Excel Object Model. Note, Excel should be installed on the server. I have found the following articles and a sample project for you:

    Sunday, December 22, 2013 7:43 PM
  • Thanks George. I have just gone through these examples. Hwever I am still wondering, how can I have mixed font attibutes for text within a cell. I used HTML for this with xls format but it does not work with xlsx format.
    Monday, December 23, 2013 1:01 PM
  • Hi CSharp_Lover

    << I am still wondering, how can I have mixed font attibutes for text within a cell>>

    This is the wrong forum to ask that question, as this forum targets the VSTO technology, not programming Excel or working with proprietary file format Excel workbooks.

    FWIW I can confirm that how Excel interprets HTML files was changed when the new file formats (xlsx) were introduced. There's no way to make Excel 2007 and later show HTML the way older versions did. That's a fact that cannot be changed.

    Since you provide absolutely no information on how you're exporting to Excel, other than the fact that you're doing so and it's not satisfactory, there's little anyone can do to help you. But from what I understand of your requirement Eugene's recommendation to transform your content directly to the Excel Open XML file format is probably the best approach.


    Cindy Meister, VSTO/Word MVP, my blog

    Wednesday, December 25, 2013 2:34 PM
    Moderator
  • Thanks Cindy for your feedback. From your statement, can you please elaborate on below statement

    "how Excel interprets HTML files was changed when the new file formats (xlsx)"

    My question is simple, what do I need to do with new interpretation of excel to display html content in cell e.g. In one excel cell I want to display below html rendered -

    Hi this is <font color="red">good</font><b>way</b>

    I dont want to use my old code whatever it is as its not complaince with xlsx format. So I am not adding it here. Just want to know how can achieve above mentioned simple functionlity using OPEN XML in xlsx format.

    Thursday, December 26, 2013 2:22 PM
  • Hi,

    Firstly, VSTO use Office Primary Interop Assemblies to do Office automation. With Office PIA, we can set formats of any cell in the workbook. Before using Office PIA, we need to install Office.

    Secondly, Microsoft don’t recommend server-side Automation of Office, please refer to Considerations for server-side Automation of Office. So I’m afraid we don’t use Office PIA to do Office automation.

    Thirdly, if you want to export data and set formats to workbook on server-side, I recommend you to use

    Open XML SDK 2.5 for Office to achieve the goal, you can download from Open XML SDK 2.5 for Microsoft Office. There are many samples from MSDN: Spreadsheets (Open XML SDK).

    Fourthly, if you want to use HttpContext Class to export, as Cindy mentioned, it is not related to the topic of this forum.

    As far as I know, the file exported is not an Excel workbook but can be opened with Excel application.

    Here is a single file which export from web and use HttpContext, I opened it with notepad:

    I found a possible solution from Export DataTable to Excel with Formatting in C#. Also, you can get help from ASP.NET web form forum.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, December 27, 2013 5:07 AM
    Moderator