Unverified Commit ca43c651 authored by xuri's avatar xuri

Update test for addTable

parent c922c32f
...@@ -396,10 +396,7 @@ func (f *File) addNameSpaces(path string, ns xml.Attr) { ...@@ -396,10 +396,7 @@ func (f *File) addNameSpaces(path string, ns xml.Attr) {
if !exist { if !exist {
f.xmlAttr[path] = append(f.xmlAttr[path], ns) f.xmlAttr[path] = append(f.xmlAttr[path], ns)
if !mc { if !mc {
f.xmlAttr[path] = append(f.xmlAttr[path], xml.Attr{ f.xmlAttr[path] = append(f.xmlAttr[path], SourceRelationshipCompatibility)
Name: xml.Name{Local: "mc", Space: "xmlns"},
Value: SourceRelationshipCompatibility,
})
} }
if !ignore { if !ignore {
f.xmlAttr[path] = append(f.xmlAttr[path], xml.Attr{ f.xmlAttr[path] = append(f.xmlAttr[path], xml.Attr{
......
...@@ -287,14 +287,8 @@ func (f *File) AutoFilter(sheet, hcell, vcell, format string) error { ...@@ -287,14 +287,8 @@ func (f *File) AutoFilter(sheet, hcell, vcell, format string) error {
} }
formatSet, _ := parseAutoFilterSet(format) formatSet, _ := parseAutoFilterSet(format)
cellStart, _ := CoordinatesToCellName(hcol, hrow)
var cellStart, cellEnd string cellEnd, _ := CoordinatesToCellName(vcol, vrow)
if cellStart, err = CoordinatesToCellName(hcol, hrow); err != nil {
return err
}
if cellEnd, err = CoordinatesToCellName(vcol, vrow); err != nil {
return err
}
ref, filterDB := cellStart+":"+cellEnd, "_xlnm._FilterDatabase" ref, filterDB := cellStart+":"+cellEnd, "_xlnm._FilterDatabase"
wb := f.workbookReader() wb := f.workbookReader()
sheetID := f.GetSheetIndex(sheet) sheetID := f.GetSheetIndex(sheet)
......
...@@ -29,6 +29,8 @@ func TestAddTable(t *testing.T) { ...@@ -29,6 +29,8 @@ func TestAddTable(t *testing.T) {
t.FailNow() t.FailNow()
} }
// Test add table in not exist worksheet.
assert.EqualError(t, f.AddTable("SheetN", "B26", "A21", `{}`), "sheet SheetN is not exist")
// Test add table with illegal formatset. // Test add table with illegal formatset.
assert.EqualError(t, f.AddTable("Sheet1", "B26", "A21", `{x}`), "invalid character 'x' looking for beginning of object key string") assert.EqualError(t, f.AddTable("Sheet1", "B26", "A21", `{x}`), "invalid character 'x' looking for beginning of object key string")
// Test add table with illegal cell coordinates. // Test add table with illegal cell coordinates.
...@@ -100,6 +102,10 @@ func TestAutoFilterError(t *testing.T) { ...@@ -100,6 +102,10 @@ func TestAutoFilterError(t *testing.T) {
}) })
} }
assert.EqualError(t, f.autoFilter("SheetN", "A1", 1, 1, &formatAutoFilter{
Column: "A",
Expression: "",
}), "sheet SheetN is not exist")
assert.EqualError(t, f.autoFilter("Sheet1", "A1", 1, 1, &formatAutoFilter{ assert.EqualError(t, f.autoFilter("Sheet1", "A1", 1, 1, &formatAutoFilter{
Column: "-", Column: "-",
Expression: "-", Expression: "-",
......
...@@ -15,9 +15,10 @@ import "encoding/xml" ...@@ -15,9 +15,10 @@ import "encoding/xml"
// Source relationship and namespace. // Source relationship and namespace.
var ( var (
SourceRelationship = xml.Attr{Name: xml.Name{Local: "r", Space: "xmlns"}, Value: "http://schemas.openxmlformats.org/officeDocument/2006/relationships"} SourceRelationship = xml.Attr{Name: xml.Name{Local: "r", Space: "xmlns"}, Value: "http://schemas.openxmlformats.org/officeDocument/2006/relationships"}
NameSpaceSpreadSheet = xml.Attr{Name: xml.Name{Local: "xmlns"}, Value: "http://schemas.openxmlformats.org/spreadsheetml/2006/main"} SourceRelationshipCompatibility = xml.Attr{Name: xml.Name{Local: "mc", Space: "xmlns"}, Value: "http://schemas.openxmlformats.org/markup-compatibility/2006"}
NameSpaceSpreadSheetX14 = xml.Attr{Name: xml.Name{Local: "x14", Space: "xmlns"}, Value: "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"} NameSpaceSpreadSheet = xml.Attr{Name: xml.Name{Local: "xmlns"}, Value: "http://schemas.openxmlformats.org/spreadsheetml/2006/main"}
NameSpaceSpreadSheetX14 = xml.Attr{Name: xml.Name{Local: "x14", Space: "xmlns"}, Value: "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"}
) )
// Source relationship and namespace. // Source relationship and namespace.
...@@ -39,7 +40,6 @@ const ( ...@@ -39,7 +40,6 @@ const (
SourceRelationshipChart201506 = "http://schemas.microsoft.com/office/drawing/2015/06/chart" SourceRelationshipChart201506 = "http://schemas.microsoft.com/office/drawing/2015/06/chart"
SourceRelationshipChart20070802 = "http://schemas.microsoft.com/office/drawing/2007/8/2/chart" SourceRelationshipChart20070802 = "http://schemas.microsoft.com/office/drawing/2007/8/2/chart"
SourceRelationshipChart2014 = "http://schemas.microsoft.com/office/drawing/2014/chart" SourceRelationshipChart2014 = "http://schemas.microsoft.com/office/drawing/2014/chart"
SourceRelationshipCompatibility = "http://schemas.openxmlformats.org/markup-compatibility/2006"
NameSpaceDrawingML = "http://schemas.openxmlformats.org/drawingml/2006/main" NameSpaceDrawingML = "http://schemas.openxmlformats.org/drawingml/2006/main"
NameSpaceDrawingMLChart = "http://schemas.openxmlformats.org/drawingml/2006/chart" NameSpaceDrawingMLChart = "http://schemas.openxmlformats.org/drawingml/2006/chart"
NameSpaceDrawingMLSpreadSheet = "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing" NameSpaceDrawingMLSpreadSheet = "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment