VintaSoft Imaging .NET SDK 15.1: Documentation for .NET developer
Vintasoft.Imaging.Office.OpenXml.Editor.Xlsx Namespace / XlsxDocumentSheet Class / FindCell Methods / FindCell(Int32,Int32) Method
Syntax Example Requirements SeeAlso
In This Topic
FindCell(Int32,Int32) Method (XlsxDocumentSheet)
In This Topic
Finds the table cell at specified location in sheet.
Syntax
'Declaration

Public Overloads Function FindCell( _
ByVal columnNumber
The column number.
As System.Int32, _
ByVal rowNumber
The row number.
As System.Int32 _
) As XlsxDocumentSheetCell
public XlsxDocumentSheetCell FindCell(
System.Int32 columnNumber,
System.Int32 rowNumber
)

Parameters

columnNumber
The column number.
rowNumber
The row number.

Return Value

The tabel cell.
Example

This C#/VB.NET code shows how to set barcode image in XLSX document (example uses template document SetBarcodeImage_template.xlsx):


Public Shared Sub XlsxSetBarcodeImageExample()
    Dim templateFilename As String = "SetBarcodeImage_template.xlsx"
    Dim outFilename As String = "SetBarcodeImage.xlsx"
    Dim outPdfFilename As String = "SetBarcodeImage.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 with text "Invoice number:"
        Dim cell As Vintasoft.Imaging.Office.OpenXml.Editor.Xlsx.XlsxDocumentSheetCell = sheet.FindCell("Invoice number:")

        ' get barcode value as text of next row after "Invoice number:" cell
        Dim barcodeValue As String = sheet.FindCell(cell.ColumnNumber, cell.RowNumber + 1).Text

        ' create and setup barcode generator
        Dim barcodeGenerator As New Vintasoft.Barcode.BarcodeWriter()
        barcodeGenerator.Settings.Barcode = Vintasoft.Barcode.BarcodeType.QR
        barcodeGenerator.Settings.SetWidth(200)
        barcodeGenerator.Settings.Value = barcodeValue

        ' generate barcode image
        Using barcodeImage As New Vintasoft.Imaging.VintasoftImage(barcodeGenerator.GetBarcodeAsVintasoftBitmap(), True)
            ' crop barcode to the rectangular image
            barcodeImage.Crop(New System.Drawing.Rectangle(0, 0, barcodeImage.Width, barcodeImage.Width))

            ' set barcode image to the DOCX image at index 0
            editor.Images(0).SetImage(barcodeImage)
        End Using

        ' 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 XlsxSetBarcodeImageExample()
{
    string templateFilename = "SetBarcodeImage_template.xlsx";
    string outFilename = "SetBarcodeImage.xlsx";
    string outPdfFilename = "SetBarcodeImage.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 with text "Invoice number:"
        Vintasoft.Imaging.Office.OpenXml.Editor.Xlsx.XlsxDocumentSheetCell cell = sheet.FindCell("Invoice number:");

        // get barcode value as text of next row after "Invoice number:" cell
        string barcodeValue = sheet.FindCell(cell.ColumnNumber, cell.RowNumber + 1).Text;

        // create and setup barcode generator
        Vintasoft.Barcode.BarcodeWriter barcodeGenerator = new Vintasoft.Barcode.BarcodeWriter();
        barcodeGenerator.Settings.Barcode = Vintasoft.Barcode.BarcodeType.QR;
        barcodeGenerator.Settings.SetWidth(200);
        barcodeGenerator.Settings.Value = barcodeValue;

        // generate barcode image
        using (Vintasoft.Imaging.VintasoftImage barcodeImage =
            new Vintasoft.Imaging.VintasoftImage(barcodeGenerator.GetBarcodeAsVintasoftBitmap(), true))
        {
            // crop barcode to the rectangular image
            barcodeImage.Crop(new System.Drawing.Rectangle(0, 0, barcodeImage.Width, barcodeImage.Width));

            // set barcode image to the DOCX image at index 0
            editor.Images[0].SetImage(barcodeImage);
        }

        // save changed document to a XLSX file
        editor.Save(outFilename);

        // export changed document to a PDF document
        editor.Export(outPdfFilename);
    }
}

Requirements

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

See Also