opening .xlsx in office 2003

筅森魡賤 提交于 2019-12-24 21:05:35

问题


I have created a .xlsx using openxml. I am not able to open this file in office 2003.. I have also tried using compatibility pack but still the file does not open. What can be done if i need to generate .xlsx that can be opened in office 2003 as well.

Code i am using to generate .xlsx is :

public static void HelloWorldXlsx(string docName)
{
    SpreadsheetDocument package = SpreadsheetDocument.Create(docName, SpreadsheetDocumentType.Workbook);
    package.AddWorkbookPart();
    package.WorkbookPart.Workbook = new Workbook();
    WorksheetPart wspart = package.WorkbookPart.AddNewPart<WorksheetPart>();

    Cell cell = new Cell();
    cell.DataType = CellValues.InlineString;
    cell.InlineString = new InlineString(new DocumentFormat.OpenXml.Spreadsheet.Text("Hello World!")); 

    wspart.Worksheet = new Worksheet(new SheetData(new Row(cell)));

    wspart.Worksheet.Save();
    package.WorkbookPart.Workbook.AppendChild(new Sheets());
    Sheet sheet = new Sheet();

    sheet.Id = package.WorkbookPart.GetIdOfPart(wspart);
    sheet.SheetId = 1;
    sheet.Name = "Hello !";
    package.WorkbookPart.Workbook.GetFirstChild<Sheets>().AppendChild<Sheet>(sheet);
    package.WorkbookPart.Workbook.Save();
    package.Close();
}

回答1:


Thanks for suggestion. I got the answer to my question .. I had not set cellReference property of Cell in my code.



来源:https://stackoverflow.com/questions/1271520/opening-xlsx-in-office-2003

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!