在Office 2003中打开.xlsx [英] opening .xlsx in office 2003

查看:122
本文介绍了在Office 2003中打开.xlsx的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用openxml创建了一个.xlsx. 我无法在Office 2003中打开此文件.我也尝试过使用兼容包,但是仍然无法打开该文件.如果我需要生成也可以在Office 2003中打开的.xlsx,该怎么办?

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.

我用来生成.xlsx的代码是:

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();
}

推荐答案

感谢您的建议.我得到了我问题的答案..我没有在代码中设置Cell的cellReference属性.

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

这篇关于在Office 2003中打开.xlsx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆