openxml-sdk

Open XML SDK adding gradient border to all drawings

ε祈祈猫儿з 提交于 2019-12-25 04:14:12
问题 I'm working on my own project, and i want to apply gradient borders to all pictures in the ms word file . On my research, i was only able to insert new pictures with assigned parameters. The problem is, that i can't figure it out how to access and customize existing picture elements . I thought, that if i create new elements, and then simply append them to a file it will do the work, but somehow Drawing element drops an error because it belongs to a tree or smth. Below is the code fragment of

XML cells incorrectly being shown as SharedStrings when they are not

有些话、适合烂在心里 提交于 2019-12-25 03:54:14
问题 I am parsing through an Excel spreadsheet and had some problems with some values, so on the suggestions of a stackoverflow member, I evaluated them as shared strings. Now, however, some of the cell values are not shared strings and my conditional still evaluates as true, meaning they are SharedStrings. So I am wondering if my code for evaluating these is correct or maybe there's something wrong with the Excel spreadsheets I've been working with. Here is an example conditional, which in this

XML cells incorrectly being shown as SharedStrings when they are not

若如初见. 提交于 2019-12-25 03:54:05
问题 I am parsing through an Excel spreadsheet and had some problems with some values, so on the suggestions of a stackoverflow member, I evaluated them as shared strings. Now, however, some of the cell values are not shared strings and my conditional still evaluates as true, meaning they are SharedStrings. So I am wondering if my code for evaluating these is correct or maybe there's something wrong with the Excel spreadsheets I've been working with. Here is an example conditional, which in this

Search And Replace Text in OPENXML (Added file)

假如想象 提交于 2019-12-25 03:34:38
问题 I know there is alot of posts on it, BUT nothing worked for my problem: Im using OPENxml to create word document, and I am adding some ready files to the document during the creation. I want to change some text in the file that I am adding after the document is ready. So thats what I tried: First creating the document: fileName = HttpContext.Current.Server.MapPath("~/reports/"+fileName+".docx"); using (var doc = WordprocessingDocument.Create( fileName, WordprocessingDocumentType.Document)) {

The word document cannot be opened after adding excel charts to it using OpenXml

会有一股神秘感。 提交于 2019-12-25 01:14:20
问题 I tried to append excel charts to a word document using OpenXml. But after that when I'm trying to open the document it says "Sorry we can't open the file.docx because we found a problem with its contents" This is my code public void excelToImages(string excelSource, string wordSource) {using (SpreadsheetDocument document = SpreadsheetDocument.Open(excelSource, true)) { WorkbookPart workbookPart = document.WorkbookPart; string relId = workbookPart.Workbook.Descendants<Sheet>().First(s =>

Inserting HTML into Word Using OpenXML

偶尔善良 提交于 2019-12-25 01:08:08
问题 I have some HTML stored in a database that I want to insert into a Word document using DocumentFormat.OpenXml. Inspired by the article here, I tried the following code. mainPart.AddAlternativeFormatImportPart(AlternativeFormatImportPartType.Xhtml, String.Format("<html><body>{0}</body></html>", html)); But this gives me the following error. '(My HTML Here)' ID is not a valid XSD ID I really don't understand this error. Does anyone know what I'm doing wrong? Also, my biggest concern about this

C# : Editing/saving/Sending a docx document

谁都会走 提交于 2019-12-25 00:01:24
问题 Been strugling with a lot of problems. Using OpenXML on a ASP.NET Core server, I want to create a new docx document based on a template one. Once this document is fully saved, I want it to be sent to my client so he can download it directly. Here's my code : public IActionResult Post([FromBody] Consultant consultant) { using (Stream templateStream = new MemoryStream(Properties.Resources.templateDossierTech)) using (WordprocessingDocument template = WordprocessingDocument.Open(templateStream,

XLSX file via OpenXml SDK Both Valid and Invalid

不打扰是莪最后的温柔 提交于 2019-12-24 19:59:29
问题 I have a program which exports a System.Data.DataTable to an XLSX / OpenXml Spreadsheet. Finally have it mostly working. However when opening the Spreadsheet in Excel, Excel complains about the file being invalid, and needing repair, giving this message... We found a problem with some content in . Do you want us to try to recover as much as we can? If you trust the source of the workbook, clik Yes. If I click Yes, it comes back with this message... Clicking the log file and opening that, just

How to generate thumbnail image for a PPTX file in C#?

為{幸葍}努か 提交于 2019-12-24 17:43:24
问题 Is there any way to use the OpenXML library to automatically create a thumbnail image for a PPTX file? I am building a small C# ASP.NET web application that is used to build PPTX files from a library of PPTX files. One of the requirements is to show a thumbnail image for each PPTX file in the library. I would like to automate this as the people that will be using the system don't know how to create screen shots. 回答1: Pptx file already have it, unziping the file you can find id. ;) 回答2: There

Specify Encoding Format when Export DataTable to Excel with Open Xml SDK in c#

元气小坏坏 提交于 2019-12-24 07:03:10
问题 I am just trying to export datatable as excel using open xml. Referred the below approach, Export DataTable to Excel with Open Xml SDK in c# But I couldn't specify the encoding format of the excel created. I want to save or create the excecl with UTF-Encoding-8 format. Can some one help on how could the formatting specificed using Open XML 回答1: To save an Excel file with UTF-Encoding-8 Format you need to specify the encoding format under Tools -> Web Options -> Encoding while saving the excel