tests/testthat/test_sheets.R

context("sheets")
xl.workbook.add()
sheets = xl.sheets()
xl.sheet.add("Second")
xl.sheet.add("First",before="Second")
for (sheet in sheets) xl.sheet.delete(sheet) # only 'First' and 'Second' exist in workbook now
expect_identical(xl.sheets(), c("First","Second"))
xl.sheet.activate("Second") #last sheet activated 
xl.sheet.duplicate()
expect_identical(xl.sheets(), c("First", "Second", "Second (2)"))
new_sheet_name = xl.sheet.duplicate(before = "First")
expect_identical(new_sheet_name, "Second (3)")
expect_identical(xl.sheets(), c("Second (3)", "First", "Second", "Second (2)"))
expect_equal(xl.sheet.name(), "Second (3)")
expect_error(xl.sheet.name("First"))
expect_equal(xl.sheet.name("Third"), "Third")
expect_equal(xl.sheets(), c("Third", "First", "Second", "Second (2)"))
expect_equal(xl.sheet.visible("Third"), TRUE)
xl.sheet.hide()
expect_equal(xl.sheet.visible("Third"), FALSE)
xl.sheet.hide("Second")
expect_error(xl.sheet.activate("Second"))
expect_error(xl.sheet.activate(3))
expect_equal(xl.sheet.visible("Second"), FALSE)
xl.sheet.show("Third")
expect_equal(xl.sheet.visible("Third"), TRUE)
xl.sheet.show("Second")
expect_equal(xl.sheet.visible("Second"), TRUE)
xl.workbook.close()
gdemin/excel.link documentation built on Feb. 10, 2024, 5 p.m.