openxml

Append multiple DOCX files together

时光怂恿深爱的人放手 提交于 2019-12-17 15:34:48
问题 I need to use C# programatically to append several preexisting docx files into a single, long docx file - including special markups like bullets and images. Header and footer information will be stripped out, so those won't be around to cause any problems. I can find plenty of information about manipulating an individual docx file with .NET Framework 3, but nothing easy or obvious about how you would merge files. There is also a third-party program (Acronis.Words) that will do it, but it is

How to convert HSSFWorkbook to XSSFWorkbook using Apache POI?

余生颓废 提交于 2019-12-17 11:02:20
问题 How to convert org.apache.poi.hssf.usermodel.HSSFWorkbook to org.apache.poi.xssf.usermodel.XSSFWorkbook in Apache POI? Environment : JSE1.6 JBossAS 4.3.2 POI 3.7 回答1: this code has been adapted from what I found here on coderanch forum public final class ExcelDocumentConverter { public static XSSFWorkbook convertWorkbookHSSFToXSSF(HSSFWorkbook source) { XSSFWorkbook retVal = new XSSFWorkbook(); for (int i = 0; i < source.getNumberOfSheets(); i++) { XSSFSheet xssfSheet = retVal.createSheet();

How do I read data from a spreadsheet using the OpenXML Format SDK?

吃可爱长大的小学妹 提交于 2019-12-17 10:44:07
问题 I need to read data from a single worksheet in an Excel 2007 workbook using the Open XML SDK 2.0. I have spent a lot of time searching for basic guidelines to doing this, but I have only found help on creating spreadsheets. How do I iterate rows in a worksheet and then iterate the cells in each row, using this SDK? 回答1: The way I do this is with Linq. There are lots of sample around on this subject from using the SDK to just going with pure Open XML (no SDK). Take a look at: Office Open XML

Save modified WordprocessingDocument to new file

↘锁芯ラ 提交于 2019-12-17 09:19:41
问题 I'm attempting to open a Word document, change some text and then save the changes to a new document. I can get the first bit done using the code below but I can't figure out how to save the changes to a NEW document (specifying the path and file name). using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Diagnostics; using DocumentFormat.OpenXml.Packaging; using System.IO; namespace WordTest { class Program { static void Main(string[] args) {

Merge multiple word documents into one Open Xml

北城余情 提交于 2019-12-17 08:53:14
问题 I have around 10 word documents which I generate using open xml and other stuff. Now I would like to create another word document and one by one I would like to join them into this newly created document. I wish to use open xml, any hint would be appreciable. Below is my code: private void CreateSampleWordDocument() { //string sourceFile = Path.Combine("D:\\GeneralLetter.dot"); //string destinationFile = Path.Combine("D:\\New.doc"); string sourceFile = Path.Combine("D:\\GeneralWelcomeLetter

OPENXML with xmlns:dt

荒凉一梦 提交于 2019-12-17 07:51:12
问题 Use OPENXML to get dt element in MSSQL 2005. How can I get xmlns:dt element in xml? For example, get a result set of two rows that list product id and country code. 121403 GBR 121403 USA declare @xmldata xml set @xmldata = '<?xml version="1.0"?> <data xmlns="http://www.aaa.com/master_browse_response" xmlns:dt="http://www.aaa.com/DataTypes"> <products> <product> <product_id><![CDATA[121403]]></product_id> <countries> <dt:country>GBR</dt:country> <dt:country>USA</dt:country> </countries> <

Inserting newlines in Word using OpenXML

◇◆丶佛笑我妖孽 提交于 2019-12-17 07:22:56
问题 I am using openxml WordProcessingDocument to open a Word template and replace placeholder x1 with a string. This works fine unless I need the string to contain a newline. How can I replace x1 with text may contain newlines that word would recognise? I have tried \n \r but these do not work Just to explain further when the word template is opened I read it into a StreamReader then use .Replace to replace x1. 回答1: To insert newlines, you have to add a Break instance to the Run . Example: run

What indicates an Office Open XML Cell contains a Date/Time value?

房东的猫 提交于 2019-12-17 04:48:23
问题 I'm reading an .xlsx file using the Office Open XML SDK and am confused about reading Date/Time values. One of my spreadsheets has this markup (generated by Excel 2010) <x:row r="2" spans="1:22" xmlns:x="http://schemas.openxmlformats.org/spreadsheetml/2006/main"> <x:c r="A2" t="s"> <x:v>56</x:v> </x:c> <x:c r="B2" t="s"> <x:v>64</x:v> </x:c> . . . <x:c r="J2" s="9"> <x:v>17145</x:v> </x:c> Cell J2 has a date serial value in it and a style attribute s="9" . However, the Office Open XML

Export DataTable to Excel with Open Xml SDK in c#

 ̄綄美尐妖づ 提交于 2019-12-17 04:48:15
问题 Sorry for my english please. I'm new in open xml sdk. My program have ability to export some data and DataTable to Excel file (template) In the template I insert the data to some placeholders. It's works very good, but I need to insert a DataTable too... My sample code: using (Stream OutStream = new MemoryStream()) { // read teamplate using (var fileStream = File.OpenRead(templatePath)) fileStream.CopyTo(OutStream); // exporting Exporting(OutStream); // to start OutStream.Seek(0L, SeekOrigin

OpenXML tag search

蹲街弑〆低调 提交于 2019-12-17 03:43:33
问题 I'm writing a .NET application that should read a .docx file nearby 200 pages long (trough DocumentFormat.OpenXML 2.5) to find all the occurences of certain tags that the document should contain. To be clear I'm not looking for OpenXML tags but rather tags that should be set into the document by the document writer as placeholder for values I need to fill up in a second stage. Such tags should be in the following format: <!TAG!> (where TAG can be an arbitrary sequence of characters). As I