zoukankan
html css js c++ java
Microsoft SDK for Open XML Formats Technology Preview 发布
下载地址:
http://go.microsoft.com/?linkid=6899996
帮助文档里有一个创建docx的例子,下面提供一个创建xlsx的例子
using
System;
using
System.Collections.Generic;
using
System.Text;
using
Microsoft.Office.DocumentFormat.OpenXml.Packaging;
using
System.IO;
using
System.Xml;
namespace
ConsoleApplication1
{
class
Program
{
static
void
Main(
string
[] args)
{
CreateNewXlsDocument(
"
c:\\temp.xlsx
"
);
}
public
static
void
CreateNewXlsDocument(
string
document)
{
using
(SpreadsheetDocument doc
=
SpreadsheetDocument.Create(document, SpreadsheetDocumentType.Workbook))
{
WorkbookPart mainPart
=
doc.AddWorkbookPart();
WorksheetPart part
=
mainPart.AddNewPart
<
WorksheetPart
>
();
string
rid
=
mainPart.GetIdOfPart(part);
SetWorkBookContect(mainPart,rid);
SetWorkSheetContect(part);
}
}
public
static
void
SetWorkBookContect(WorkbookPart part,
string
rid)
{
const
string
xlsXml
=
@"
<?xml version=""1.0"" encoding=""UTF-8"" standalone=""yes""?><workbook xmlns=""http://schemas.openxmlformats.org/spreadsheetml/2006/main"" xmlns:r=""http://schemas.openxmlformats.org/officeDocument/2006/relationships""><sheets><sheet name=""Sheet1"" sheetId=""1"" r:id=""{0}""/></sheets></workbook>
"
;
using
(Stream stream
=
part.GetStream())
{
byte
[] buf
=
(
new
UTF8Encoding()).GetBytes(
string
.Format(xlsXml,rid));
stream.Write(buf,
0
, buf.Length);
}
}
public
static
void
SetWorkSheetContect(WorksheetPart part)
{
const
string
xlsXml
=
@"
<?xml version=""1.0"" encoding=""UTF-8"" standalone=""yes""?>
<worksheet xmlns=""http://schemas.openxmlformats.org/spreadsheetml/2006/main"" xmlns:r=""http://schemas.openxmlformats.org/officeDocument/2006/relationships"">
<sheetData>
<row>
<c t=""inlineStr"">
<is>
<t>测试</t>
</is>
</c>
</row>
</sheetData>
</worksheet>
"
;
using
(Stream stream
=
part.GetStream())
{
byte
[] buf
=
(
new
UTF8Encoding()).GetBytes(xlsXml);
stream.Write(buf,
0
, buf.Length);
}
}
}
}
查看全文
相关阅读:
发布机制:功能开关发布
发布机制:蛮力发布
发布机制-滚动式发布:百科
发布机制-灰度发布:百科
发布机制:金丝雀发布
发布机制-蓝绿发布:百科
发布机制:百科
服务安全-IAM:百科
Workflow-产品:泛微工作流引擎
android Fragment
原文地址:https://www.cnblogs.com/derek/p/773932.html
最新文章
设置网卡工作模式
centos修改时区,设置时间
linux oracle10g安装
tomcat6-7配置管理用户
centos firefox中文乱码问题
ubuntukylin提取root权限及mongoDB部署
ubuntu 运行android sdk 下的工具adb报bash: ./adb: No such file or directory
Android ADB使用
NetFilter
CodeForces 2A
热门文章
[多校2015.02.1004 dp] hdu 5303 Delicious Apples
BEGINNING SHAREPOINT® 2013 DEVELOPMENT 第1章节--SharePoint 2013 介绍 SharePoint 管理中心
honeyd蜜罐配置和web监听脚本
Be Happy.——我的ACM退役贴
HTML5 postMessage 和 onmessage API 具体应用
一个简单的排序问题
考研资料分享
[Unity3D]Unity3D游戏开发之异步记载场景并实现进度条读取效果
java接口的高级应用
发布机制-A/B 测试:百科
Copyright © 2011-2022 走看看