tests/testthat/test.with.workbook.R

test_that("with.workbook correctly loads data from an XLS file - check if named regions can be correctly referenced", {
  wb.xls <- loadWorkbook(rsrc("testWithWorkbook.xls"), create = FALSE)
  with(
    wb.xls,
    {
      expect_true(all(dim(AA) == c(8, 3)), info = "XLS: Check dimensions of sheet AA")
      expect_true(all(dim(BB) == c(5, 5)), info = "XLS: Check dimensions of sheet BB")
    },
    header = FALSE
  )
})

test_that("with.workbook correctly loads data from an XLSX file - check if named regions can be correctly referenced", {
  wb.xlsx <- loadWorkbook(rsrc("testWithWorkbook.xlsx"), create = FALSE)
  with(
    wb.xlsx,
    {
      expect_true(all(dim(AA) == c(8, 3)), info = "XLSX: Check dimensions of sheet AA")
      expect_true(all(dim(BB) == c(5, 5)), info = "XLSX: Check dimensions of sheet BB")
    },
    header = FALSE
  )
})

Try the XLConnect package in your browser

Any scripts or data that you put into this service are public.

XLConnect documentation built on Feb. 24, 2026, 9:06 a.m.