c# openxml_openxml sdk简要指南c

c# openxml C#概念 (C# CONCEPTS) 本文演示了如何以编程方式在C#控制台应用程序中使用Excel Document。 (The articles demonstrate how to play with Excel Document in C# Console Application programmatically.) 先决条件 (Prerequisites)Ins...
摘要由CSDN通过智能技术生成

c# openxml

C#概念 (C# CONCEPTS)

本文演示了如何以编程方式在C#控制台应用程序中使用Excel Document。 (The articles demonstrate how to play with Excel Document in C# Console Application programmatically.)

先决条件 (Prerequisites)

Install below packages from NuGet

从NuGet安装以下软件包

DocumentFormat.OpenXml

Following “Assembly Directives” are used to compile the code

以下“汇编指令”用于编译代码

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

创建电子表格文档 (Create a Spreadsheet Document)

To build an Excel document, construct an instance of the “SpreadsheetDocument” class.

要构建Excel文档,请构建“ SpreadsheetDocument”类的实例。

SpreadsheetDocument spreadsheetDocument = SpreadsheetDocument.Create
(
filepath,
SpreadsheetDocumentType.Workbook
);

There are many constructor overloads for SpreadsheetDocument, but the above instance takes two arguments.

SpreadsheetDocument有许多构造函数重载但以上实例带有两个参数。

  • File Path: The destination path to save the final excel file.

    文件路径:保存最终Excel文件的目标路径。
  • SpreadSheetDocumentType: It specifies the type of excel document.

    SpreadSheetDocumentType:它指定excel文档的类型。

SDK中可用的文档类型枚举: (Available document types enum in SDK:)

Select the suitable SpreadsheetDocumentType and ensure that the file path where the output excel file is saved is correct, matching filename extension used.

选择合适的SpreadsheetDocumentType并确保保存输出excel文件的文件路径正确,且匹配使用的文件扩展名。

If the SpreadsheetDocumentType does not match the output file name extension, an error occurs when you open the file.

如果SpreadsheetDocumentType与输出文件扩展名不匹配,则在打开文件时发生错误。

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值