我们正在尝试使用OOXML生成MS Excel工作簿并使用SSIS填充数据.我们能够生成工作簿和工作表,还能够在标题单元格中创建列和插入数据.我们还可以使用SSIS填充数据.
但Sheet(DocumentFormat.OpenXml.Spreadsheet.Sheet)和所有单元格(DocumentFormat.OpenXml.Spreadsheet.Cell)成为OpenXmlUnknownElement.因此,我们无法使用以下代码读取工作表/单元格:Sheet sheet = workbookPart.Workbook.Descendants<Sheet>().Where(s => s.Name == "Sheet1").SingleOrDefault<Sheet>();
如果我们首先使用MS Excel打开并保存,我们可以读取相同的文件.有谁知道如何解决这个问题?
我试图使用OpenXML从ASP.NET Web服务器写出一个Excel文件.我有大约2100条记录,大约需要20-30秒才能完成.我能以任何方式加快速度吗?从db中检索2100行只需要几分之一秒.不知道为什么在内存中操作它们会花费更长的时间.
注意:ExcelWriter是我们的自定义类,但它的所有方法都直接来自此链接中的代码,http://msdn.microsoft.com/en-us/library/cc861607.aspx
public static MemoryStream CreateThingReport(List<Thing> things, MemoryStream template)
{
SpreadsheetDocument spreadsheet = SpreadsheetDocument.Open(template, true);
WorksheetPart workSheetPart = spreadsheet.WorkbookPart.WorksheetParts.First();
SharedStringTablePart sharedStringPart = spreadsheet.WorkbookPart.GetPartsOfType<SharedStringTablePart>().First();
Cell cell = null;
int index = 0;
//create cell formatting for header text
Alignment wrappedAlignment = new Alignment { WrapText = true };
uint rowOffset = 2;
foreach (Thing t in things)
{
//Received Date
cell = ExcelWriter.InsertCellIntoWorksheet("A", rowOffset, workSheetPart);
index = ExcelWriter.InsertSharedStringItem(t.CreateDate.ToShortDateString(), sharedStringPart);
cell.CellValue = new CellValue(index.ToString());
cell.DataType = new DocumentFormat.OpenXml.EnumValue<CellValues>(CellValues.SharedString);
//Car Part …Run Code Online (Sandbox Code Playgroud) 我一直在寻找几个小时,我似乎无法找到一个可靠的答案.我有一个包含内容控件的现有文档,我需要使用外部数据编辑文本.如果其中一个控件的数据不存在,那么我需要用适当的通知替换文本并更改字体颜色.
我有文本条目和所有工作正常,唯一似乎无法完成其工作的部分是更改字体颜色.我当前的代码没有给我任何错误,并且正在运行这个方法就好了,但是当我查看完成的文档时,它仍然是纯黑色文本.
我的换色方法:(输入是具有相同标签的所有内容控件的列表)
public void SetBlueText(List<SdtElement> sdtElement)
{
foreach (SdtElement element in sdtElement)
{
if (element != null)
{
RunProperties runProperties = element.Descendants<RunProperties>().FirstOrDefault();
runProperties.Color = new DocumentFormat.OpenXml.Wordprocessing.Color() { Val = "0EBFE9" };
}
}
}
Run Code Online (Sandbox Code Playgroud)
此外,将这两行简化为此/具有相同的效果
element.Descendants<RunProperties>().FirstOrDefault().Color =
new DocumentFormat.OpenXml.Wordprocessing.Color() { Val = "0EBFE9" };
Run Code Online (Sandbox Code Playgroud) 有人可以帮我理解MS Excel中的共享字符串吗?我试图理解使用一些博客,但无法完全了解.每个人都在解释如何使用Open XML访问共享字符串以及存储共享字符串的位置(作为sharedstrings.xml).使用API访问很好.但,
我试过跟随.
在XLSX文件中检查单元格元素时,我找到以下公式元素:
<f t="shared" si="0"/>
Run Code Online (Sandbox Code Playgroud)
这样的公式元素是什么意思?
我想在文档的末尾添加一个分节符并添加一些文本.
我的代码如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing;
namespace WordDocManipulation
{
class Program
{
static void Main(string[] args)
{
string path = @"C:\sample.docx";
string strtxt = "Hello This is done by programmatically";
OpenAndAddTextToWordDocument(path,strtxt);
}
public static void OpenAndAddTextToWordDocument(string filepath, string txt)
{
/* I want to the below text to be added in the new section */
// Open a WordprocessingDocument for editing using the filepath.
WordprocessingDocument wordprocessingDocument =
WordprocessingDocument.Open(filepath, true);
// Assign a …Run Code Online (Sandbox Code Playgroud) 我是.net编码器,我对ColdFusion真的很新.我写了一个自动生成发票的.dll库.我需要使用ColdFusion应用程序中的库.我已经成功地将库中的类作为coldfusion对象加载,因为我可以调用这些方法.但是,我的类中有一个方法使用WordprocessingDocument,它是DocumentFormat.OpenXml.Packaging的一个类.我实际上收到此错误:
System.IO.FileNotFoundException:无法加载文件或程序集'DocumentFormat.OpenXml,Version = 2.5.5631.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35'或其依赖项之一.该系统找不到指定的文件.文件名:'DocumentFormat.OpenXml,Version = 2.5.5631.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35'位于InvoiceLibrary.DocumentHandler.ProcessDocument()的InvoiceLibrary.DocumentHandler.ConvertDocumentToDOCX(字符串文件
)
我导入了DocumentFormat.OpenXml.dll,因此是WindowsBase.dll文件
<cfObject type=".NET" name="WordprocessingDocument"
class="DocumentFormat.OpenXml.Packaging.WordprocessingDocument"
assembly="C:\Users\mydocs\Documents\Visual Studio 2012\Projects\InvoiceGenerator\InvoiceLibrary\bin\Release\DocumentFormat.OpenXml.dll,C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\WindowsBase.dll">
Run Code Online (Sandbox Code Playgroud)
我需要你的指导我做错了什么或我在这里缺少什么?
我正在从代码中读取一个元素,结果我得到了Open XML字符串.
byte[] binary = Convert.FromBase64String(template.Attributes["body"].ToString());
string bodyContent = UnicodeEncoding.UTF8.GetString(binary);
Run Code Online (Sandbox Code Playgroud)
现在,我想在memorystream中转换此字符串,以便WordProcessingDocument可以读取它,如下所示.
using (MemoryStream stream = new MemoryStream())
{
stream.Write(binary, 0, (int)binary.Length);
using (WordprocessingDocument wordDoc = wordprocessingDocument.Open(stream, true))
{
File.WriteAllBytes("C:\\data\\newFileName.docx", stream.ToArray());
}
}
Run Code Online (Sandbox Code Playgroud)
当我尝试上面的代码时,它无法打开流并引发损坏数据的错误.
XML字符串如下所示:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<?mso-application progid="Word.Document"?>
<w:wordDocument xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml"
xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:w10="urn:schemas-microsoft-com:office:word"
xmlns:sl="http://schemas.microsoft.com/schemaLibrary/2003/core"
xmlns:aml="http://schemas.microsoft.com/aml/2001/core"
xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns:wsp="http://schemas.microsoft.com/office/word/2003/wordml/sp2"
w:macrosPresent="no" w:embeddedObjPresent="no" w:ocxPresent="no" xml:space="preserve">
<w:ignoreElements w:val="http://schemas.microsoft.com/office/word/2003/wordml/sp2"/>
<o:DocumentProperties>
<o:Title>Follow-up to Our Meeting</o:Title><o:Author>Microsoft Corporation</o:Author><o:LastAuthor>ASI User</o:LastAuthor><o:Revision>2</o:Revision><o:TotalTime>0</o:TotalTime><o:Created>2007-08-10T16:40:00Z</o:Created><o:LastSaved>2007-08-10T16:40:00Z</o:LastSaved><o:Pages>1</o:Pages><o:Words>178</o:Words><o:Characters>1019</o:Characters><o:Company>Microsoft Corporation</o:Company><o:Lines>8</o:Lines><o:Paragraphs>2</o:Paragraphs><o:CharactersWithSpaces>1195</o:CharactersWithSpaces><o:Version>11.8134</o:Version>
</o:DocumentProperties>
<w:fonts>
<w:defaultFonts w:ascii="Times New Roman" w:fareast="SimSun" w:h-ansi="Times New Roman" w:cs="Times New Roman"/>
<w:font w:name="SimSun"><w:altName w:val="??"/><w:panose-1 …Run Code Online (Sandbox Code Playgroud)有没有办法在EPPlus中实现这一目标?我在互联网上找到的唯一的事情就是对特定数据进行分组,例如:
AAA ---> AAA 5 occurrences
AAA BBB 2 occurences
BBB
BBB
AAA
AAA
AAA
Run Code Online (Sandbox Code Playgroud)
但在截图中看起来并不像
好吧,我已经知道有一个关于此的文件,其中说明:
12.2.4.26 Relationships Transform Algorithm
13 The relationships transform takes the XML document from the Relationships part and converts it to another
14 XML document.
15 The package implementer might create relationships XML that contains content from several namespaces, along
16 with versioning instructions as defined in Part 5: “Markup Compatibility and Extensibility”. [O6.11]
17 The relationships transform algorithm is as follows:
18 Step 1: Process versioning instructions
19 1. The package implementer shall process the versioning instructions, considering that …Run Code Online (Sandbox Code Playgroud) openxml ×10
c# ×6
openxml-sdk ×4
.net ×2
excel ×2
coldfusion ×1
docx ×1
epplus ×1
excel-2010 ×1
ms-office ×1
ms-word ×1
ssis ×1
xlsx ×1
xml ×1
xps ×1