Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
此号慢热型
excelize
提交
0aa15106
excelize
项目概览
此号慢热型
/
excelize
与 Fork 源项目一致
Fork自
xuri / excelize
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
excelize
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
已验证
提交
0aa15106
编写于
7月 11, 2020
作者:
xurime
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update docs and improve compatibility
上级
42b1c814
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
59 addition
and
67 deletion
+59
-67
drawing.go
drawing.go
+0
-2
lib_test.go
lib_test.go
+3
-0
picture.go
picture.go
+6
-5
picture_test.go
picture_test.go
+5
-0
rows_test.go
rows_test.go
+2
-0
stream.go
stream.go
+1
-1
xmlStyles.go
xmlStyles.go
+7
-14
xmlTheme.go
xmlTheme.go
+3
-3
xmlWorkbook.go
xmlWorkbook.go
+4
-4
xmlWorksheet.go
xmlWorksheet.go
+28
-38
未找到文件。
drawing.go
浏览文件 @
0aa15106
...
...
@@ -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
)}
}
...
...
lib_test.go
浏览文件 @
0aa15106
...
...
@@ -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
)
{
...
...
picture.go
浏览文件 @
0aa15106
...
...
@@ -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
}
}
}
}
...
...
picture_test.go
浏览文件 @
0aa15106
...
...
@@ -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
)
{
...
...
rows_test.go
浏览文件 @
0aa15106
...
...
@@ -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
)
{
...
...
stream.go
浏览文件 @
0aa15106
...
...
@@ -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
{
...
...
xmlStyles.go
浏览文件 @
0aa15106
...
...
@@ -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"`
}
...
...
xmlTheme.go
浏览文件 @
0aa15106
...
...
@@ -123,9 +123,9 @@ type xlsxBgFillStyleLst struct {
BgFillStyleLst
string
`xml:",innerxml"`
}
// xlsxClrScheme
maps to children of the clrScheme element in the namespac
e
//
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 Them
e
//
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"`
...
...
xmlWorkbook.go
浏览文件 @
0aa15106
...
...
@@ -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"`
}
...
...
xmlWorksheet.go
浏览文件 @
0aa15106
...
...
@@ -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
// co
lumn is co
nsidered 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 hav
e
//
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 th
e
//
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 namespac
e
//
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 th
e
//
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
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录