VintaSoft Imaging .NET SDK 14.0: Documentation for .NET developer
Vintasoft.Imaging.Office.OpenXml.Editor.Xlsx Namespace / XlsxDocumentSheetCell Class
Members Object Syntax Example Hierarchy Requirements SeeAlso
In This Topic
    XlsxDocumentSheetCell Class
    In This Topic
    Represents the worksheet cell of XLSX document.
    Object Model
    XlsxDocumentSheet OpenXmlDocumentTableRow OpenXmlDocumentElement OpenXmlDocumentElement OpenXmlDocumentElement OpenXmlDocumentElement OpenXmlDocumentElementCollection OpenXmlDocumentRootElement XlsxDocumentSheetCell
    Syntax
    'Declaration
    
    <DefaultMemberAttribute("Item")>
    Public Class XlsxDocumentSheetCell
       Inherits Vintasoft.Imaging.Office.OpenXml.Editor.OpenXmlDocumentTableCell
    
    
    [DefaultMember("Item")]
    public __gc class XlsxDocumentSheetCell : public Vintasoft.Imaging.Office.OpenXml.Editor.OpenXmlDocumentTableCell*
    
    
    [DefaultMember("Item")]
    public ref class XlsxDocumentSheetCell : public Vintasoft.Imaging.Office.OpenXml.Editor.OpenXmlDocumentTableCell^
    
    
    Example

    This C#/VB.NET code shows how to find cell by reference and set cell formula (example uses template document XlsxCell_template.xlsx):

    
    Public Shared Sub XlsxCellExample()
        Dim templateFilename As String = "XlsxCell_template.xlsx"
        Dim outFilename As String = "XlsxCell.xlsx"
        Dim outPdfFilename As String = "XlsxCell.pdf"
    
        ' create XlsxDocumentEditor that allows to edit file "SetBarcodeImage_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)
    
            ' find cell by reference (A1 format) and set cell fill color
            sheet.FindCellByName("B3").SetFillColor(System.Drawing.Color.Red)
            sheet.FindCellByName("D3").SetFillColor(System.Drawing.Color.Yellow)
            sheet.FindCellByName("C4").SetFillColor(System.Drawing.Color.Green)
            sheet.FindCellByName("D5").SetFillColor(System.Drawing.Color.Blue)
            sheet.FindCellByName("B5").SetFillColor(System.Drawing.Color.Pink)
    
            ' set cell formula
            Dim cellD16 As Vintasoft.Imaging.Office.OpenXml.Editor.Xlsx.XlsxDocumentSheetCell = sheet.FindCellByName("D8")
            cellD16.Formula = "SUM(B8,C8)"
            cellD16.Number = sheet.FindCellByName("B8").Number + sheet.FindCellByName("C8").Number
    
            ' find cell that contains text "[cell_name]"
            Dim cell As Vintasoft.Imaging.Office.OpenXml.Editor.Xlsx.XlsxDocumentSheetCell = sheet.FindCell("[cell_name]")
            ' set cell text to cell name in A1 format
            cell.Text = cell.Name
    
            ' 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 XlsxCellExample()
    {
        string templateFilename = "XlsxCell_template.xlsx";
        string outFilename = "XlsxCell.xlsx";
        string outPdfFilename = "XlsxCell.pdf";
    
        // create XlsxDocumentEditor that allows to edit file "SetBarcodeImage_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];
    
            // find cell by reference (A1 format) and set cell fill color
            sheet.FindCellByName("B3").SetFillColor(System.Drawing.Color.Red);
            sheet.FindCellByName("D3").SetFillColor(System.Drawing.Color.Yellow);
            sheet.FindCellByName("C4").SetFillColor(System.Drawing.Color.Green);
            sheet.FindCellByName("D5").SetFillColor(System.Drawing.Color.Blue);
            sheet.FindCellByName("B5").SetFillColor(System.Drawing.Color.Pink);
    
            // set cell formula
            Vintasoft.Imaging.Office.OpenXml.Editor.Xlsx.XlsxDocumentSheetCell cellD16 = sheet.FindCellByName("D8");
            cellD16.Formula = "SUM(B8,C8)";
            cellD16.Number = sheet.FindCellByName("B8").Number + sheet.FindCellByName("C8").Number;
    
            // find cell that contains text "[cell_name]"
            Vintasoft.Imaging.Office.OpenXml.Editor.Xlsx.XlsxDocumentSheetCell cell = sheet.FindCell("[cell_name]");
            // set cell text to cell name in A1 format
            cell.Text = cell.Name;
    
            // save changed document to a XLSX file
            editor.Save(outFilename);
    
            // export changed document to a PDF document
            editor.Export(outPdfFilename);
        }
    }
    
    

    Inheritance Hierarchy

    System.Object
       Vintasoft.Imaging.Office.OpenXml.Editor.OpenXmlDocumentElement
          Vintasoft.Imaging.Office.OpenXml.Editor.OpenXmlDocumentTableCell
             Vintasoft.Imaging.Office.OpenXml.Editor.Xlsx.XlsxDocumentSheetCell

    Requirements

    Target Platforms: .NET9; .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    See Also