openxml

Excel accepts some characters whereas OpenXml has error

爱⌒轻易说出口 提交于 2019-12-21 22:32:10
问题 i have a string that i want to export on excel file with openxml component in C#. My text has '\u001f' character and openxml has error with this character. error text: "hexadecimal value 0x1f, is an invalid character". i copy that test directly to excel and no problem and copy is success. Does OpenXml have configs for solving this problem or How i can solve this problem. thanks. 回答1: You need to write it using the format _xHHHH_ where H represents a hexadecimal character. In your particular

Using a template with OpenXML and SAX

佐手、 提交于 2019-12-21 19:39:36
问题 I'm creating a large XLSX file from a datatable, using the SAX method proposed in Parsing and Reading Large Excel Files with the Open XML SDK. I'm using an XLSX file as a template. The method described in that post works fine to substitute a new sheet in for an existing one, but I want to copy the header row from the sheet in the template (string values, formatting, etc), instead of just using the header row from the datatable as the original code does. I've tried the code below, but the XLSX

How can I get the Worksheetpart from name or sheet ID in OpenXML?

℡╲_俬逩灬. 提交于 2019-12-21 12:49:09
问题 The following creates an XLSX, adds two worksheets with some data. I then want to be able to get the spreadsheet later based on name (or preferably the id) so I can add/modify the sheets at a later point in time. I'm stuck on how to get the sheet again where the code is incomplete below. Sub Main() Using doc As SpreadsheetDocument = SpreadsheetDocument.Create(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "c:\temp\fubar.xlsx"), SpreadsheetDocumentType.Workbook) Dim currSheet As

How to insert a shape in a powerpoint slide using OpenXML

女生的网名这么多〃 提交于 2019-12-21 07:26:17
问题 This question could seem rather basic, but how do I insert a shape (i. e. a rectangle) in a slide using OpenXML in c#? I've searched around and all I see is "create a slide with the shape and use the SDK Productivity Tool to reflect the code. That's not really helpful :( 回答1: After hitting my head against the wall for a while, finally I took the advice, created a slide with the shape and used the tool to reflect the code. So for next generations, here is a brief explanation of how to do it by

How can i get actual used range for modified excels using Epplus?

泄露秘密 提交于 2019-12-21 07:15:13
问题 I am reading data from excel to datable using EPPlus. After reading an excel sheet with 10 rows of record, I modified the excel sheet by removing existing data and kept data for only one row. But when I am reading the modified excel it still reading 10 rows (1 with value and remaining as null fields) to data table. How can limit this? I am using following code for reading Excel. using (var pck = new OfficeOpenXml.ExcelPackage()) { using (var stream = File.OpenRead(FilePath)) { pck.Load(stream

How to create a excel file with sheets in C#?

限于喜欢 提交于 2019-12-21 06:25:43
问题 I want to create an excel file say personinfo.xls with one work sheet say Person . Is there a way in C# to do it ? 回答1: You can do that with MyXLS. I have used it in a few project with great success. Its opensource. 回答2: Have you tried the Excel Interop? Is this for excel 2003/2007? If it is excel 2007 xml you can try Carlos SpreadsheetGear ExcelPackage (Codeplex) 回答3: Try this class: using System; using System.Collections.Generic; using System.Text; using System.IO; using Excel = Microsoft

Unit testing an application that talks to microsoft word via OpenXML

时光毁灭记忆、已成空白 提交于 2019-12-21 06:18:27
问题 I am modifying an application that does a lot of 'talking' to Microsoft Word. Right now, COM interop is used but I need to change it to Open XML. I would like to introduce unit tests for this but I am not sure how to do this. This is one of the operations for example: A template word document contains some bookmarks. The application fills up the bookmarks with some dynamic data. Can I check if this executes correctly? 回答1: In order to unit test things like this, you need to design seams at

How can I modify the foreground and background color of an OpenXML TableCell?

 ̄綄美尐妖づ 提交于 2019-12-21 04:12:28
问题 I'm creating the table cell as follows: private static TableCell GetHeaderCell(string cellText) { var tc = new TableCell(new Paragraph(new Run(new Text(cellText)))); return tc; } I want it to be blue with white text. I've tried the following, but it doesn't work; when I try to open the document I get an error that there is a problem with the contents: private static TableCell GetHeaderCell(string cellText) { var props = new TableCellProperties(); var solidFill = new SolidFill(); var

C# OPENXML XLSX Custom Column width

半城伤御伤魂 提交于 2019-12-21 03:32:46
问题 C# newbie here! I need to create a small console application to convert CSV files into XLSX files. I have all my styles and data working, but I want to set a different (from default) width on some columns. And after a day of searching and reading I still can't figure out how to get it to work. As an example I want to set columns A and C to a width of 30 Set column D to a width of 20 Any help or tips would be great. My code right now below using System; using System.Linq; using DocumentFormat

Word VSTO - Why paraId is sometimes missing

℡╲_俬逩灬. 提交于 2019-12-20 06:25:22
问题 I'm retrieving paragraph stylenames from openXML and using paraID property to get the right one. During testing i noticed that depending on the word document the attribute might not be present on any of the paragraphs. I do know that this is a internal runtime paragraph id for Word. So the question is: What generates the paraId properties on the paragraphs, can't seem to figure this out. ps. I don't want to use get_style() since that is waay too slooooow... edit: added code example This is in