适用于Microsoft Office的Open XML SDK 2.0需要.net framework3.5SP1 [英] Open XML SDK 2.0 for Microsoft Office need .net framework3.5SP1

查看:114
本文介绍了适用于Microsoft Office的Open XML SDK 2.0需要.net framework3.5SP1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道为什么用于Microsoft Office的Open XML SDK 2.0"需要.net Framework 3.5 SP1吗?

我安装了.net framework 4..
它包含.net框架,不是吗?

SDK安装程序需要.net framework 3.5 sp1.

如果我的SDK开发的.net4应用程序分发了其他计算机,那么他们是否需要框架3.5 sp1?

Do anyone know why "Open XML SDK 2.0 for Microsoft Office" need .net framework 3.5 SP1?

I installed .net framework 4.
It contains .net framework,doesn''t it?

The SDK installer required .net framework 3.5 sp1.

If my .net4 app which is made by the SDK distribute other machines, do they need framework 3.5 sp1?

推荐答案

我不确定100%,但是我会认为这是因为SDK最初是基于.NET 3.5 SP1构建的?

无论哪种方式,请查看 [
I''m not 100% sure, but I would assume it was because the SDK was originally built upon .NET 3.5 SP1?

Eitherway, take a look at this[^]. .NET 4.0 is just a superset of .NET 3.5, so they shouldn''t require .NET 3.5.


这是我能够创建xlsx文件的示例代码. /> 它可以在仅安装.NET4的另一台计算机上工作.
关键是将位于"C:\ Program Files \ Open XML SDK \ V2.0 \ lib"的DocumentFormat.OpenXml文件复制到示例应用程序exe的同一目录中.
Here is my sample code of being able to create a xlsx file.
It worked on another machine which .NET4 only installed.
The point was copying the DocumentFormat.OpenXml files, which located at ''C:\Program Files\Open XML SDK\V2.0\lib'', into the same directory of the sample app''s exe.

using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;
using DocumentFormat.OpenXml;


namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            String filepath = @"c:\2.xlsx";
            // Create a spreadsheet document by supplying the filepath.
            // By default, AutoSave = true, Editable = true, and Type = xlsx.
            SpreadsheetDocument spreadsheetDocument = SpreadsheetDocument.
                Create(filepath, SpreadsheetDocumentType.Workbook);

            // Add a WorkbookPart to the document.
            WorkbookPart workbookpart =spreadsheetDocument.AddWorkbookPart();
            workbookpart.Workbook = new Workbook();

            // Add a WorksheetPart to the WorkbookPart.
            WorksheetPart worksheetPart=workbookpart.AddNewPart<worksheetpart>();
            worksheetPart.Worksheet = new Worksheet(new SheetData());

            // Add Sheets to the Workbook.
            Sheets sheets = spreadsheetDocument.WorkbookPart.Workbook.
                AppendChild<sheets>(new Sheets());

            // Append a new worksheet and associate it with the workbook.
            Sheet sheet = new Sheet()
            {
                Id = spreadsheetDocument.WorkbookPart.
                    GetIdOfPart(worksheetPart),
                SheetId = 1,
                Name = "mySheet"
            };

            sheets.Append(sheet);

            workbookpart.Workbook.Save();

            // Close the document.
            spreadsheetDocument.Close();

            
        }

    }
}
</sheets></worksheetpart>


这篇关于适用于Microsoft Office的Open XML SDK 2.0需要.net framework3.5SP1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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