Represents the low-level editor for XLSX document.
This editor is intended for low-level editing of XSLX document, i.e. editor allows to edit document as an XLSX document:
- Edit worksheets: Sheets, AddSheet(String), RemoveSheet(XlsxDocumentSheet)
- Add styles: AddEmptyStyle, AddStyle
- Set style properties: SetStyleBorders(Int32,CellBorders), SetStyleFillColor(Int32,Nullable<VintasoftColor>), SetStyleFontProperties(Int32,FontProperties), SetStyleName(Int32,String), SetStyleNumberFormat(Int32,String), SetStyleTextProperties(Int32,TextProperties)
- Edit rows: GetRow(Int32), InsertRows(Int32,Int32), RemoveRows(Int32,Int32), FindRow(Int32), FindRow(String), Height, IsHidden, StyleIndex, InsertCopyAfterSelf, InsertCopyBeforeSelf
- Edit columns: GetColumnIsHidden(Int32), SetColumnsIsHidden(Int32,Int32,Boolean), GetColumnWidth(Int32), SetColumnsWidth(Int32,Int32,Double), SetColumnsIsHidden(Int32,Int32,Boolean), SetColumnsStyleIndex(Int32,Int32,Nullable<Int32>)
- Edit cells: FindText(String), FindTextNext(Int32,String), FindCell(String), FindCell(Int32,Int32)
- Edit defined names: AddDefinedName(DefinedName), SetDefinedName(Int32,DefinedName), RemoveDefinedName(Int32)
- Edit images: AddImage(Stream,SheetDrawingLocation), Images, SetImage(Stream)
- Edit comments: MoveComment(Int32,Int32), RemoveComment(Int32,Int32), SetComment(CellComment,XlsxDocumentSheetCellCommentTransformType), SetCommentIsVisible(Int32,Int32,Boolean), SetCommentLocation(Int32,Int32,SheetDrawingLocation,XlsxDocumentSheetCellCommentTransformType)
If you want to edit XLSX document using high-level commands (edit XLSX document as spreadsheet document), please use the SpreadsheetEditor class.
This C#/VB.NET code shows how to find and replace text in XLSX document (example uses template document FindAndReplaceText_template.xlsx):
Public Shared Sub XlsxFindAndReplaceTextExample()
Dim templateFilename As String = "FindAndReplaceText_template.xlsx"
Dim outFilename As String = "FindAndReplaceText.xlsx"
Dim outPdfFilename As String = "FindAndReplaceText.pdf"
' create XlsxDocumentEditor that allows to edit file "FindAndReplaceText_template.xlsx"
Using editor As New Vintasoft.Imaging.Office.OpenXml.Editor.Xlsx.XlsxDocumentEditor(templateFilename)
' get first sheet in XLSX document
Dim sheet As Vintasoft.Imaging.Office.OpenXml.Editor.Xlsx.XlsxDocumentSheet = editor.Sheets(0)
' replace first occurrence of text "[field1]" by text "value1"
sheet("[field1]") = "value1"
' replace all occurrences of text "[field2]" by text "value2"
sheet.ReplaceText("[field2]", "value2")
' find text content that corresponds to the text "[field3]"
Dim field3Content As Vintasoft.Imaging.Office.OpenXml.Editor.OpenXmlTextContent = sheet.FindText("[field3]")
' change text in found text content
field3Content.Text = "value3"
' replace text "[multiline_field]" by multiline text
sheet("[multiline_field]") = vbLf & "line1" & vbLf & "line2" & vbLf & "line3"
' save changed document to a XLSX file
editor.Save(outFilename)
' export changed document to a PDF document
editor.Export(outPdfFilename)
End Using
End Sub
public static void XlsxFindAndReplaceTextExample()
{
string templateFilename = "FindAndReplaceText_template.xlsx";
string outFilename = "FindAndReplaceText.xlsx";
string outPdfFilename = "FindAndReplaceText.pdf";
// create XlsxDocumentEditor that allows to edit file "FindAndReplaceText_template.xlsx"
using (Vintasoft.Imaging.Office.OpenXml.Editor.Xlsx.XlsxDocumentEditor editor =
new Vintasoft.Imaging.Office.OpenXml.Editor.Xlsx.XlsxDocumentEditor(templateFilename))
{
// get first sheet in XLSX document
Vintasoft.Imaging.Office.OpenXml.Editor.Xlsx.XlsxDocumentSheet sheet = editor.Sheets[0];
// replace first occurrence of text "[field1]" by text "value1"
sheet["[field1]"] = "value1";
// replace all occurrences of text "[field2]" by text "value2"
sheet.ReplaceText("[field2]", "value2");
// find text content that corresponds to the text "[field3]"
Vintasoft.Imaging.Office.OpenXml.Editor.OpenXmlTextContent field3Content = sheet.FindText("[field3]");
// change text in found text content
field3Content.Text = "value3";
// replace text "[multiline_field]" by multiline text
sheet["[multiline_field]"] = "\nline1\nline2\nline3";
// save changed document to a XLSX file
editor.Save(outFilename);
// export changed document to a PDF document
editor.Export(outPdfFilename);
}
}
System.Object
 Vintasoft.Imaging.Office.OpenXml.Editor.OpenXmlDocumentEditor
   Vintasoft.Imaging.Office.OpenXml.Editor.Xlsx.XlsxDocumentEditor
Target Platforms: .NET9; .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5