質問

My asp.net mvc runs on windows azure website on windows cloud. I have excel sheet with cells that take input and another cell based on formula that calculates based on the input. I am able to use open xml sdk c# code to do the following successfully on my local dev machine.

  1. pass input values to the input cell and save the worksheet.
  2. open and close the excel file using Microsoft.Office.Interop.Excel.Application object

    var excelApp = new Microsoft.Office.Interop.Excel.Application();
    Microsoft.Office.Interop.Excel.Workbook workbook = excelApp.Workbooks.OpenXML(Path.GetFullPath(filename));
    workbook.Close(true);
    excelApp.Quit();
    
  3. read the formula cell and the calculated value.

Now the problem

I need to deploy this on windows azure website where I don't want to deploy the Microsoft Excel application. How do I do step2 with out using Microsoft.Office.Interop.Excel.Application object so that I don't have to install excel on windows azure website cloud.

I have to do step2 in order for excel formula cell recalculate based on formula. I have tried removing cell and it does not work in terms of reading formula cell programmatically.

役に立ちましたか?

解決

If you are using Open Xml SDK you will not need Microsoft Excel application to be deployed in your cloud. Open XML SDK create worksheets that are in exact formats for Open XML files standards (Spreadsheet - .XLSX files)

What you can do,

  1. Do work related to formulas before creating worksheet (will sounds crazy but it's a solution)

  2. I found following resource in MSDN . It's with Open Xml SDK 2.5 and it's about formulas. According to this you can create formulas and relate them to cells - http://msdn.microsoft.com/en-us/library/office/gg278310%28v=office.15%29.aspx

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top