oficina / sheets Public

Clone
git clone https://amadan.net/oficina/sheets

Plain git — no account needed to clone.

Download

Download this file

1package xlsx
2
3import (
4 "errors"
5 "testing"
6
7 "github.com/xuri/excelize/v2"
8)
9
10// agree is the check that keeps either reader from supplying a value
11// alone. Both read the same bytes, so a real workbook rarely makes
12// them differ; this drives the check directly with a scan that says
13// something excelize does not.
14func TestAgreeRefusesAScanExcelizeDoesNotConfirm(t *testing.T) {
15 f := excelize.NewFile()
16 defer f.Close()
17 sheet := f.GetSheetList()[0]
18 if err := f.SetCellFormula(sheet, "A1", "FOO(1)"); err != nil {
19 t.Fatal(err)
20 }
21 im := &importer{f: f, sheet: sheet}
22 for name, sc := range map[string]scannedCell{
23 "a saved value excelize did not read": {HasF: true, T: "str", HasV: true, V: "3"},
24 "a declared type excelize did not read": {HasF: true, T: "b"},
25 } {
26 if err := im.agree("A1", sc); !errors.Is(err, errScanInconsistent) {
27 t.Errorf("%s: agree = %v, want errScanInconsistent", name, err)
28 }
29 }
30 // excelize holds a formula it was given in memory as t="str".
31 if err := im.agree("A1", scannedCell{HasF: true, T: "str"}); err != nil {
32 t.Errorf("matching scan: agree = %v, want nil", err)
33 }
34}
35