From 48f19f60aa3e162146a9dc4edf7b4c8cf687ec26 Mon Sep 17 00:00:00 2001 From: xuri Date: Sat, 27 Jun 2020 00:02:47 +0800 Subject: support the row element without r attribute in the worksheet --- cell_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'cell_test.go') diff --git a/cell_test.go b/cell_test.go index 45e2f24..b2b1d54 100644 --- a/cell_test.go +++ b/cell_test.go @@ -95,6 +95,23 @@ func TestSetCellBool(t *testing.T) { assert.EqualError(t, f.SetCellBool("Sheet1", "A", true), `cannot convert cell "A" to coordinates: invalid cell name "A"`) } +func TestGetCellValue(t *testing.T) { + // Test get cell value without r attribute of the row. + f := NewFile() + delete(f.Sheet, "xl/worksheets/sheet1.xml") + f.XLSX["xl/worksheets/sheet1.xml"] = []byte(`A3A4B4A7B7A8B8`) + f.checked = nil + cells := []string{"A3", "A4", "B4", "A7", "B7"} + rows, err := f.GetRows("Sheet1") + assert.Equal(t, [][]string{nil, nil, {"A3"}, {"A4", "B4"}, nil, nil, {"A7", "B7"}, {"A8", "B8"}}, rows) + assert.NoError(t, err) + for _, cell := range cells { + value, err := f.GetCellValue("Sheet1", cell) + assert.Equal(t, cell, value) + assert.NoError(t, err) + } +} + func TestGetCellFormula(t *testing.T) { // Test get cell formula on not exist worksheet. f := NewFile() -- cgit v1.2.1