openxml

How to replace text with a MS Word web add-in by preserving the formatting?

╄→尐↘猪︶ㄣ 提交于 2021-02-07 19:13:48
问题 I'm working on a simple grammar correction web add-in for MS Word. Basically, I want to get the selected text, make minimal changes and update the document with the corrected text. Currently, if I use 'text' as the coercion type, I lose formatting. If there is a table or image in the selected text, they are also gone! As I understand from the investigation I've been doing so far, openxml is the way to go. But I couldn't find any useful example on the web. How can I manipulate text by

How to replace text with a MS Word web add-in by preserving the formatting?

你说的曾经没有我的故事 提交于 2021-02-07 19:09:47
问题 I'm working on a simple grammar correction web add-in for MS Word. Basically, I want to get the selected text, make minimal changes and update the document with the corrected text. Currently, if I use 'text' as the coercion type, I lose formatting. If there is a table or image in the selected text, they are also gone! As I understand from the investigation I've been doing so far, openxml is the way to go. But I couldn't find any useful example on the web. How can I manipulate text by

How to AutoFit excel column using OpenXML Package

柔情痞子 提交于 2021-02-07 06:32:28
问题 This code to generate Excel spreadsheet Using openxml package. Please anyone tell how to auto fit its column width. OpenXmlPackage.SpreadsheetDocument spreadsheetDocument = OpenXmlPackage.SpreadsheetDocument.Create(downloadFilePath, OpenXml.SpreadsheetDocumentType.Workbook); // Add a WorkbookPart to the document. OpenXmlPackage.WorkbookPart workbookpart = spreadsheetDocument.AddWorkbookPart(); // Add a WorksheetPart to the WorkbookPart. workbookpart.Workbook = new OpenXmlSpreadsheet.Workbook(

Filling a cell with a solid color, using OpenXML that preserves otherwise existing sheet format

*爱你&永不变心* 提交于 2021-01-29 11:00:00
问题 The following takes the format of existing sheet sSheet and creates a red font (along with some timestamp content) at A19: using (SpreadsheetDocument document = SpreadsheetDocument.Open(sPath, true)) { IEnumerable<Sheet> sheets = document.WorkbookPart.Workbook.Descendants<Sheet>().Where(s => s.Name == sSheet); WorksheetPart worksheetPart = (WorksheetPart)document.WorkbookPart.GetPartById(sheets.FirstOrDefault().Id); Worksheet worksheet = worksheetPart.Worksheet; WorkbookStylesPart styles =

Writing to Excel with Open Xml gives issue after certain columns

偶尔善良 提交于 2021-01-29 02:57:08
问题 I am using C# with Open XML Format SDK 2.0, Trying to write an Excel report file. My problem is when I cross the Z column (reaching AA) the file goes corrupted and cannot be open manually by the user. Any ideas? static void Main(string[] args) { PortfolioReport report = new PortfolioReport("Keywords"); report.CreateReport(); } public PortfolioReport(string client) { string newFileName = path + client + ".xlsx"; if (File.Exists(newFileName)) { File.Delete(newFileName); } FileInfo newFile = new

Edit CustomXML with OpenXML C#

蓝咒 提交于 2021-01-28 22:50:26
问题 This is my first OpenXML project. I am trying to edit the CustomXML file of a docx file. I am trying to change this: <?xml version="1.0" encoding="UTF-8"?> <PERSON> <NAMETAG>NAME</NAMETAG> <DOBTAG>DOB</DOBTAG> <SCORE1TAG>SCORE1</SCORE1TAG> <SCORE2TAG>SCORE2</SCORE2TAG> </PERSON> To this: <?xml version="1.0" encoding="UTF-8"?> <PERSON> <NAMETAG>John Doe</NAMETAG> <DOBTAG>01/01/2020</DOBTAG> <SCORE1TAG>90.5</SCORE1TAG> <SCORE2TAG>100.0</SCORE2TAG> </PERSON> I would prefer to not use search and

C# add simple title for spreadsheet chart OpenXml

筅森魡賤 提交于 2021-01-28 11:33:58
问题 Hi!! i'm able to write charts to my XLSX file. But i'm stuck adding a simple title for every chart. No styles just simple plain text . My code is like this: String Dtitulo = "Hello chart"; DocumentFormat.OpenXml.Drawing.Charts.Title chartTitle = new DocumentFormat.OpenXml.Drawing.Charts.Title(); chartTitle.ChartText = new ChartText(); chartTitle.ChartText.RichText = new RichText(); DocumentFormat.OpenXml.Drawing.Paragraph parrafoTitulo = new DocumentFormat.OpenXml.Drawing.Paragraph();

Formula to convert .NET pixels to Excel width in OpenXML format

空扰寡人 提交于 2021-01-21 01:59:53
问题 I have spent many hours trying to determine a formula to convert .NET pixels to an Excel column width using the OpenXML format. I am using EPPlus to generate xmls documents. I'm trying to determine the width for a column that is to be Auto-sized. I am getting the number of pixels by measuring the string and then trying to convert that to the column width for OpenXML, which is measured in characters I think. I've read Microsoft's documentation on how to convert it and tried the formula they

OpenXML: Auto Size column width in Excel

老子叫甜甜 提交于 2021-01-20 15:42:27
问题 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:41:26
问题 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 =