forked from p30928647/excelize
update docs and improve compatibility
This commit is contained in:
parent
42b1c81488
commit
0aa1510694
|
@ -1001,8 +1001,6 @@ func (f *File) drawPlotAreaValAx(formatSet *formatChart) []*cAxs {
|
|||
max = nil
|
||||
}
|
||||
var logBase *attrValFloat
|
||||
// Follow OOXML requirements on
|
||||
// [https://github.com/sc34wg4/OOXMLSchemas/blob/2b074ca2c5df38b18ac118646b329b508b5bdecc/Part1/OfficeOpenXML-XMLSchema-Strict/dml-chart.xsd#L1142-L1147]
|
||||
if formatSet.YAxis.LogBase >= 2 && formatSet.YAxis.LogBase <= 1000 {
|
||||
logBase = &attrValFloat{Val: float64Ptr(formatSet.YAxis.LogBase)}
|
||||
}
|
||||
|
|
|
@ -95,6 +95,9 @@ func TestColumnNumberToName_Error(t *testing.T) {
|
|||
if assert.Error(t, err) {
|
||||
assert.Equal(t, "", out)
|
||||
}
|
||||
|
||||
_, err = ColumnNumberToName(TotalColumns + 1)
|
||||
assert.EqualError(t, err, "column number exceeds maximum limit")
|
||||
}
|
||||
|
||||
func TestSplitCellName_OK(t *testing.T) {
|
||||
|
|
11
picture.go
11
picture.go
|
@ -549,11 +549,12 @@ func (f *File) getPictureFromWsDr(row, col int, drawingRelationships string, wsD
|
|||
for _, anchor = range wsDr.TwoCellAnchor {
|
||||
if anchor.From != nil && anchor.Pic != nil {
|
||||
if anchor.From.Col == col && anchor.From.Row == row {
|
||||
drawRel = f.getDrawingRelationships(drawingRelationships,
|
||||
anchor.Pic.BlipFill.Blip.Embed)
|
||||
if _, ok = supportImageTypes[filepath.Ext(drawRel.Target)]; ok {
|
||||
ret, buf = filepath.Base(drawRel.Target), f.XLSX[strings.Replace(drawRel.Target, "..", "xl", -1)]
|
||||
return
|
||||
if drawRel = f.getDrawingRelationships(drawingRelationships,
|
||||
anchor.Pic.BlipFill.Blip.Embed); drawRel != nil {
|
||||
if _, ok = supportImageTypes[filepath.Ext(drawRel.Target)]; ok {
|
||||
ret, buf = filepath.Base(drawRel.Target), f.XLSX[strings.Replace(drawRel.Target, "..", "xl", -1)]
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -152,6 +152,11 @@ func TestGetPicture(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
assert.Empty(t, file)
|
||||
assert.Empty(t, raw)
|
||||
f, err = prepareTestBook1()
|
||||
assert.NoError(t, err)
|
||||
f.XLSX["xl/drawings/drawing1.xml"] = MacintoshCyrillicCharset
|
||||
_, _, err = f.getPicture(20, 5, "xl/drawings/drawing1.xml", "xl/drawings/_rels/drawing2.xml.rels")
|
||||
assert.EqualError(t, err, "xml decode error: XML syntax error on line 1: invalid UTF-8")
|
||||
}
|
||||
|
||||
func TestAddDrawingPicture(t *testing.T) {
|
||||
|
|
|
@ -169,6 +169,8 @@ func TestSharedStringsReader(t *testing.T) {
|
|||
f := NewFile()
|
||||
f.XLSX["xl/sharedStrings.xml"] = MacintoshCyrillicCharset
|
||||
f.sharedStringsReader()
|
||||
si := xlsxSI{}
|
||||
assert.EqualValues(t, "", si.String())
|
||||
}
|
||||
|
||||
func TestRowVisibility(t *testing.T) {
|
||||
|
|
|
@ -72,7 +72,7 @@ type StreamWriter struct {
|
|||
//
|
||||
func (f *File) NewStreamWriter(sheet string) (*StreamWriter, error) {
|
||||
sheetID := f.getSheetID(sheet)
|
||||
if sheetID == 0 {
|
||||
if sheetID == -1 {
|
||||
return nil, fmt.Errorf("sheet %s is not exist", sheet)
|
||||
}
|
||||
sw := &StreamWriter{
|
||||
|
|
21
xmlStyles.go
21
xmlStyles.go
|
@ -13,9 +13,7 @@ package excelize
|
|||
|
||||
import "encoding/xml"
|
||||
|
||||
// xlsxStyleSheet directly maps the stylesheet element in the namespace
|
||||
// http://schemas.openxmlformats.org/spreadsheetml/2006/main - currently I have
|
||||
// not checked it for completeness - it does as much as I need.
|
||||
// xlsxStyleSheet is the root element of the Styles part.
|
||||
type xlsxStyleSheet struct {
|
||||
XMLName xml.Name `xml:"http://schemas.openxmlformats.org/spreadsheetml/2006/main styleSheet"`
|
||||
NumFmts *xlsxNumFmts `xml:"numFmts,omitempty"`
|
||||
|
@ -55,9 +53,7 @@ type xlsxProtection struct {
|
|||
Locked bool `xml:"locked,attr"`
|
||||
}
|
||||
|
||||
// xlsxLine directly maps the line style element in the namespace
|
||||
// http://schemas.openxmlformats.org/spreadsheetml/2006/main - currently I have
|
||||
// not checked it for completeness - it does as much as I need.
|
||||
// xlsxLine expresses a single set of cell border.
|
||||
type xlsxLine struct {
|
||||
Style string `xml:"style,attr,omitempty"`
|
||||
Color *xlsxColor `xml:"color,omitempty"`
|
||||
|
@ -119,13 +115,10 @@ type xlsxFill struct {
|
|||
GradientFill *xlsxGradientFill `xml:"gradientFill,omitempty"`
|
||||
}
|
||||
|
||||
// xlsxPatternFill directly maps the patternFill element in the namespace
|
||||
// http://schemas.openxmlformats.org/spreadsheetml/2006/main - currently I have
|
||||
// not checked it for completeness - it does as much as I need. This element is
|
||||
// used to specify cell fill information for pattern and solid color cell fills.
|
||||
// For solid cell fills (no pattern), fgColor is used. For cell fills with
|
||||
// patterns specified, then the cell fill color is specified by the bgColor
|
||||
// element.
|
||||
// xlsxPatternFill is used to specify cell fill information for pattern and
|
||||
// solid color cell fills. For solid cell fills (no pattern), fgColor is used.
|
||||
// For cell fills with patterns specified, then the cell fill color is
|
||||
// specified by the bgColor element.
|
||||
type xlsxPatternFill struct {
|
||||
PatternType string `xml:"patternType,attr,omitempty"`
|
||||
FgColor xlsxColor `xml:"fgColor,omitempty"`
|
||||
|
@ -303,7 +296,7 @@ type xlsxNumFmts struct {
|
|||
// format properties which indicate how to format and render the numeric value
|
||||
// of a cell.
|
||||
type xlsxNumFmt struct {
|
||||
NumFmtID int `xml:"numFmtId,attr,omitempty"`
|
||||
NumFmtID int `xml:"numFmtId,attr"`
|
||||
FormatCode string `xml:"formatCode,attr,omitempty"`
|
||||
}
|
||||
|
||||
|
|
|
@ -123,9 +123,9 @@ type xlsxBgFillStyleLst struct {
|
|||
BgFillStyleLst string `xml:",innerxml"`
|
||||
}
|
||||
|
||||
// xlsxClrScheme maps to children of the clrScheme element in the namespace
|
||||
// http://schemas.openxmlformats.org/drawingml/2006/main - currently I have
|
||||
// not checked it for completeness - it does as much as I need.
|
||||
// xlsxClrScheme specifies the theme color, stored in the document's Theme
|
||||
// part to which the value of this theme color shall be mapped. This mapping
|
||||
// enables multiple theme colors to be chained together.
|
||||
type xlsxClrSchemeEl struct {
|
||||
XMLName xml.Name
|
||||
SysClr *xlsxSysClr `xml:"sysClr"`
|
||||
|
|
|
@ -27,9 +27,9 @@ type xlsxRelationship struct {
|
|||
TargetMode string `xml:",attr,omitempty"`
|
||||
}
|
||||
|
||||
// xlsxWorkbook directly maps the workbook element from the namespace
|
||||
// http://schemas.openxmlformats.org/spreadsheetml/2006/main - currently I have
|
||||
// not checked it for completeness - it does as much as I need.
|
||||
// xlsxWorkbook contains elements and attributes that encompass the data
|
||||
// content of the workbook. The workbook's child elements each have their own
|
||||
// subclause references.
|
||||
type xlsxWorkbook struct {
|
||||
XMLName xml.Name `xml:"http://schemas.openxmlformats.org/spreadsheetml/2006/main workbook"`
|
||||
FileVersion *xlsxFileVersion `xml:"fileVersion"`
|
||||
|
@ -153,7 +153,7 @@ type xlsxSheets struct {
|
|||
type xlsxSheet struct {
|
||||
Name string `xml:"name,attr,omitempty"`
|
||||
SheetID int `xml:"sheetId,attr,omitempty"`
|
||||
ID string `xml:"http://schemas.openxmlformats.org/officeDocument/2006/relationships id,attr,omitempty"`
|
||||
ID string `xml:"http://schemas.openxmlformats.org/officeDocument/2006/relationships id,attr"`
|
||||
State string `xml:"state,attr,omitempty"`
|
||||
}
|
||||
|
||||
|
|
|
@ -165,25 +165,20 @@ type xlsxSheetFormatPr struct {
|
|||
OutlineLevelCol uint8 `xml:"outlineLevelCol,attr,omitempty"`
|
||||
}
|
||||
|
||||
// xlsxSheetViews directly maps the sheetViews element in the namespace
|
||||
// http://schemas.openxmlformats.org/spreadsheetml/2006/main - Worksheet views
|
||||
// collection.
|
||||
// xlsxSheetViews represents worksheet views collection.
|
||||
type xlsxSheetViews struct {
|
||||
XMLName xml.Name `xml:"sheetViews"`
|
||||
SheetView []xlsxSheetView `xml:"sheetView"`
|
||||
}
|
||||
|
||||
// xlsxSheetView directly maps the sheetView element in the namespace
|
||||
// http://schemas.openxmlformats.org/spreadsheetml/2006/main - currently I have
|
||||
// not checked it for completeness - it does as much as I need. A single sheet
|
||||
// view definition. When more than one sheet view is defined in the file, it
|
||||
// means that when opening the workbook, each sheet view corresponds to a
|
||||
// separate window within the spreadsheet application, where each window is
|
||||
// showing the particular sheet containing the same workbookViewId value, the
|
||||
// last sheetView definition is loaded, and the others are discarded. When
|
||||
// multiple windows are viewing the same sheet, multiple sheetView elements
|
||||
// (with corresponding workbookView entries) are saved.
|
||||
// See https://docs.microsoft.com/en-us/dotnet/api/documentformat.openxml.spreadsheet.sheetview
|
||||
// xlsxSheetView represents a single sheet view definition. When more than one
|
||||
// sheet view is defined in the file, it means that when opening the workbook,
|
||||
// each sheet view corresponds to a separate window within the spreadsheet
|
||||
// application, where each window is showing the particular sheet containing
|
||||
// the same workbookViewId value, the last sheetView definition is loaded, and
|
||||
// the others are discarded. When multiple windows are viewing the same sheet,
|
||||
// multiple sheetView elements (with corresponding workbookView entries) are
|
||||
// saved.
|
||||
type xlsxSheetView struct {
|
||||
WindowProtection bool `xml:"windowProtection,attr,omitempty"`
|
||||
ShowFormulas bool `xml:"showFormulas,attr,omitempty"`
|
||||
|
@ -245,31 +240,27 @@ type xlsxSheetPr struct {
|
|||
PageSetUpPr *xlsxPageSetUpPr `xml:"pageSetUpPr,omitempty"`
|
||||
}
|
||||
|
||||
// xlsxOutlinePr maps to the outlinePr element
|
||||
// SummaryBelow allows you to adjust the direction of grouper controls
|
||||
// xlsxOutlinePr maps to the outlinePr element. SummaryBelow allows you to
|
||||
// adjust the direction of grouper controls.
|
||||
type xlsxOutlinePr struct {
|
||||
SummaryBelow bool `xml:"summaryBelow,attr"`
|
||||
}
|
||||
|
||||
// xlsxPageSetUpPr directly maps the pageSetupPr element in the namespace
|
||||
// http://schemas.openxmlformats.org/spreadsheetml/2006/main - Page setup
|
||||
// properties of the worksheet.
|
||||
// xlsxPageSetUpPr expresses page setup properties of the worksheet.
|
||||
type xlsxPageSetUpPr struct {
|
||||
AutoPageBreaks bool `xml:"autoPageBreaks,attr,omitempty"`
|
||||
FitToPage bool `xml:"fitToPage,attr,omitempty"` // Flag indicating whether the Fit to Page print option is enabled.
|
||||
FitToPage bool `xml:"fitToPage,attr,omitempty"`
|
||||
}
|
||||
|
||||
// xlsxTabColor directly maps the tabColor element in the namespace currently I
|
||||
// have not checked it for completeness - it does as much as I need.
|
||||
// xlsxTabColor represents background color of the sheet tab.
|
||||
type xlsxTabColor struct {
|
||||
RGB string `xml:"rgb,attr,omitempty"`
|
||||
Theme int `xml:"theme,attr,omitempty"`
|
||||
Tint float64 `xml:"tint,attr,omitempty"`
|
||||
}
|
||||
|
||||
// xlsxCols directly maps the cols element in the namespace
|
||||
// http://schemas.openxmlformats.org/spreadsheetml/2006/main - currently I have
|
||||
// not checked it for completeness - it does as much as I need.
|
||||
// xlsxCols defines column width and column formatting for one or more columns
|
||||
// of the worksheet.
|
||||
type xlsxCols struct {
|
||||
XMLName xml.Name `xml:"cols"`
|
||||
Col []xlsxCol `xml:"col"`
|
||||
|
@ -293,18 +284,18 @@ type xlsxCol struct {
|
|||
// xlsxDimension directly maps the dimension element in the namespace
|
||||
// http://schemas.openxmlformats.org/spreadsheetml/2006/main - This element
|
||||
// specifies the used range of the worksheet. It specifies the row and column
|
||||
// bounds of used cells in the worksheet. This is optional and is not required.
|
||||
// Used cells include cells with formulas, text content, and cell formatting.
|
||||
// When an entire column is formatted, only the first cell in that column is
|
||||
// considered used.
|
||||
// bounds of used cells in the worksheet. This is optional and is not
|
||||
// required. Used cells include cells with formulas, text content, and cell
|
||||
// formatting. When an entire column is formatted, only the first cell in that
|
||||
// column is considered used.
|
||||
type xlsxDimension struct {
|
||||
XMLName xml.Name `xml:"dimension"`
|
||||
Ref string `xml:"ref,attr"`
|
||||
}
|
||||
|
||||
// xlsxSheetData directly maps the sheetData element in the namespace
|
||||
// http://schemas.openxmlformats.org/spreadsheetml/2006/main - currently I have
|
||||
// not checked it for completeness - it does as much as I need.
|
||||
// xlsxSheetData collection represents the cell table itself. This collection
|
||||
// expresses information about each cell, grouped together by rows in the
|
||||
// worksheet.
|
||||
type xlsxSheetData struct {
|
||||
XMLName xml.Name `xml:"sheetData"`
|
||||
Row []xlsxRow `xml:"row"`
|
||||
|
@ -440,9 +431,9 @@ type DataValidation struct {
|
|||
Formula2 string `xml:",innerxml"`
|
||||
}
|
||||
|
||||
// xlsxC directly maps the c element in the namespace
|
||||
// http://schemas.openxmlformats.org/spreadsheetml/2006/main - currently I have
|
||||
// not checked it for completeness - it does as much as I need.
|
||||
// xlsxC collection represents a cell in the worksheet. Information about the
|
||||
// cell's location (reference), value, data type, formatting, and formula is
|
||||
// expressed here.
|
||||
//
|
||||
// This simple type is restricted to the values listed in the following table:
|
||||
//
|
||||
|
@ -472,9 +463,8 @@ func (c *xlsxC) hasValue() bool {
|
|||
return c.S != 0 || c.V != "" || c.F != nil || c.T != ""
|
||||
}
|
||||
|
||||
// xlsxF directly maps the f element in the namespace
|
||||
// http://schemas.openxmlformats.org/spreadsheetml/2006/main - currently I have
|
||||
// not checked it for completeness - it does as much as I need.
|
||||
// xlsxF represents a formula for the cell. The formula expression is
|
||||
// contained in the character node of this element.
|
||||
type xlsxF struct {
|
||||
Content string `xml:",chardata"`
|
||||
T string `xml:"t,attr,omitempty"` // Formula type
|
||||
|
|
Loading…
Reference in New Issue