openxml

OpenXML: Auto Size column width in Excel

自古美人都是妖i 提交于 2021-01-20 15:41:01
问题 I have written a code to generate Excel file using OpenXML. Below is the code which generates the Columns in the Excel. Worksheet worksheet = new Worksheet(); Columns columns = new Columns(); int numCols = dt1.Columns.Count; for (int col = 0; col < numCols; col++) { Column c = CreateColumnData((UInt32)col + 1, (UInt32)numCols + 1, 20.42578125D); columns.Append(c); } worksheet.Append(columns); Also, I tried below line to create columns. Column c = new Column { Min = (UInt32Value)1U, Max =

OpenXML: Auto Size column width in Excel

▼魔方 西西 提交于 2021-01-20 15:40:07
问题 I have written a code to generate Excel file using OpenXML. Below is the code which generates the Columns in the Excel. Worksheet worksheet = new Worksheet(); Columns columns = new Columns(); int numCols = dt1.Columns.Count; for (int col = 0; col < numCols; col++) { Column c = CreateColumnData((UInt32)col + 1, (UInt32)numCols + 1, 20.42578125D); columns.Append(c); } worksheet.Append(columns); Also, I tried below line to create columns. Column c = new Column { Min = (UInt32Value)1U, Max =

C# OpenXML PowerPoint How to get Slide Duration

寵の児 提交于 2021-01-05 09:14:31
问题 How can I get total slide duration time in PPTX file inculde effect? using (PresentationDocument doc = PresentationDocument.Open(@"C:\powerpoint\sample.pptx", true)) { // Get the presentation part of the document. PresentationPart presentationPart = doc.PresentationPart; // No presentation part? Something is wrong with the document. if (presentationPart == null) { throw new ArgumentException("fileName"); } Console.WriteLine(presentationPart.SlideParts.Count() + "count"); // I want to get like

C# OpenXML PowerPoint How to get Slide Duration

大兔子大兔子 提交于 2021-01-05 09:13:10
问题 How can I get total slide duration time in PPTX file inculde effect? using (PresentationDocument doc = PresentationDocument.Open(@"C:\powerpoint\sample.pptx", true)) { // Get the presentation part of the document. PresentationPart presentationPart = doc.PresentationPart; // No presentation part? Something is wrong with the document. if (presentationPart == null) { throw new ArgumentException("fileName"); } Console.WriteLine(presentationPart.SlideParts.Count() + "count"); // I want to get like

How to insert a newline in PowerPoint (PPTX) in OpenXML / PresentationML / C#

对着背影说爱祢 提交于 2021-01-01 04:36:27
问题 While Word and PowerPoint both use OpenXML, newlines are handled differently. In Word/WordprocessingML you can run.Append(new Break()) (see here) to insert a newline. Unfortunately in PresentationML this leads to a nonvalid presentation and with errors when loading it in PowerPoint. How to add a newline in the TextBody of a PowerPoint Shape ? 回答1: The Open XML Productivity Tool of Open Office SDK 2.5 has this great Reflect Code tool to get C# code of whatever OpenXML file you have. But

How to read o:xml with powershell?

∥☆過路亽.° 提交于 2020-12-13 04:24:06
问题 I have following xml file but don't know how to read it with Powershell, Anyone can help with? Thanks! I need to get the url value from Powershell. <o:OfficeConfig xmlns:o="urn:xxx:xxx:xxx"> <o:services> <o:service o:name="xxxx"> <o:url>https://xxx.xxx</o:url> </o:service> </o:services> </o:OfficeConfig> Thanks in advance! 回答1: You can take advantage of the fact that PowerShell's convenient, property-based adaptation of the XML DOM essentially ignores namespaces, allowing to you simply drill

OpenXML - Cell.DateType is null

≯℡__Kan透↙ 提交于 2020-12-05 05:35:40
问题 I can't determine when a Cell is a date. I noticed the DataType is null so I can't distinguish if it's a Number of a Date. I am using the next code to extract the cells: WorksheetPart worksheetPart = (WorksheetPart)workbookPart.GetPartById(worksheetId); SheetData sheetData = worksheetPart.Worksheet.GetFirstChild<SheetData>(); Row[] rows = worksheetPart.Worksheet.Descendants<Row>().ToArray(); for (int i = 0; i < rows.Length; i++) { List<Cell> cells = rows[i].Elements<Cell>().ToList(); foreach

OpenXML - Cell.DateType is null

爱⌒轻易说出口 提交于 2020-12-05 05:35:35
问题 I can't determine when a Cell is a date. I noticed the DataType is null so I can't distinguish if it's a Number of a Date. I am using the next code to extract the cells: WorksheetPart worksheetPart = (WorksheetPart)workbookPart.GetPartById(worksheetId); SheetData sheetData = worksheetPart.Worksheet.GetFirstChild<SheetData>(); Row[] rows = worksheetPart.Worksheet.Descendants<Row>().ToArray(); for (int i = 0; i < rows.Length; i++) { List<Cell> cells = rows[i].Elements<Cell>().ToList(); foreach