cells: Get the XML nodes for all of the cells in a Worksheet

cellsR Documentation

Get the XML nodes for all of the cells in a Worksheet

Description

These functions allow one to obtain the XML nodes in a work sheet and then one can extract the values directly or modify any of them.

Usage

cells(sheet, notEmpty = TRUE,
       xquery = if (notEmpty)
                  "//x:sheetData/*/x:c[x:v or x:is]"
                else
                  "//x:sheetData/*/x:c",
       cells = getNodeSet(sheet@content, xquery, "x"))

Arguments

sheet

the Worksheet-class object

notEmpty

a logical value that controls whether we only return cells that contain a value, or if FALSE we include cells that are empty.

xquery

the XPath query string that is used to obtain the cell nodes

cells

a list of the cell nodes. This is very rarely ever supplied by the caller.

Value

A list of XML nodes return via getNodeSet.

Author(s)

Duncan Temple Lang

Examples


  w = workbook(system.file("SampleDocs", "Workbook1.xlsx", package = "RExcelXML"))
  sh = w[[1]]
  k = cells(sh)
  names(k)

   # those cells in column A.
  k[grepl("^A", names(k))]

    # Just the cells in column 'A' via XPath
  k = cells(sh, xquery = "//x:c[starts-with(@r, 'A')]")
  names(k)

duncantl/RExcelXML documentation built on Nov. 23, 2023, 4:21 p.m.