提交 52796f6e 编写于 作者: xurime's avatar xurime

Format commants, break comments after 80 characters.

上级 f05df2a0
......@@ -6,8 +6,8 @@ import (
"strings"
)
// GetCellValue provide function get value from cell by given sheet index and axis in XLSX file.
// The value of the merged cell is not available currently.
// GetCellValue provide function get value from cell by given sheet index and
// axis in XLSX file. The value of the merged cell is not available currently.
func (f *File) GetCellValue(sheet string, axis string) string {
axis = strings.ToUpper(axis)
var xlsx xlsxWorksheet
......@@ -50,7 +50,8 @@ func (f *File) GetCellValue(sheet string, axis string) string {
return ""
}
// GetCellFormula provide function get formula from cell by given sheet index and axis in XLSX file.
// GetCellFormula provide function get formula from cell by given sheet index
// and axis in XLSX file.
func (f *File) GetCellFormula(sheet string, axis string) string {
axis = strings.ToUpper(axis)
var xlsx xlsxWorksheet
......
......@@ -5,8 +5,8 @@ import (
"strings"
)
// SetColWidth provides function to set the width of a single column or multiple columns.
// For example:
// SetColWidth provides function to set the width of a single column or multiple
// columns. For example:
//
// xlsx := excelize.CreateFile()
// xlsx.SetColWidth("Sheet1", "A", "H", 20)
......
......@@ -8,15 +8,15 @@ import (
"strings"
)
// File define a populated xlsx.File struct.
// File define a populated XLSX file struct.
type File struct {
XLSX map[string]string
Path string
SheetCount int
}
// OpenFile take the name of an XLSX file and returns a populated
// xlsx.File struct for it.
// OpenFile take the name of an XLSX file and returns a populated XLSX file
// struct for it.
func OpenFile(filename string) (*File, error) {
var f *zip.ReadCloser
var err error
......@@ -110,7 +110,8 @@ func (f *File) SetCellStr(sheet string, axis string, value string) {
f.saveFileList(name, replaceWorkSheetsRelationshipsNameSpace(string(output)))
}
// SetCellDefault provides function to set string type value of a cell as default format without escaping the cell.
// SetCellDefault provides function to set string type value of a cell as
// default format without escaping the cell.
func (f *File) SetCellDefault(sheet string, axis string, value string) {
axis = strings.ToUpper(axis)
var xlsx xlsxWorksheet
......@@ -203,7 +204,8 @@ func completeRow(xlsx xlsxWorksheet, row int, cell int) xlsxWorksheet {
return xlsx
}
// Replace xl/worksheets/sheet%d.xml XML tags to self-closing for compatible Office Excel 2007.
// Replace xl/worksheets/sheet%d.xml XML tags to self-closing for compatible
// Office Excel 2007.
func replaceWorkSheetsRelationshipsNameSpace(workbookMarshal string) string {
oldXmlns := `<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">`
newXmlns := `<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mx="http://schemas.microsoft.com/office/mac/excel/2008/main" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mv="urn:schemas-microsoft-com:mac:vml" xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac" xmlns:xm="http://schemas.microsoft.com/office/excel/2006/main">`
......@@ -211,7 +213,7 @@ func replaceWorkSheetsRelationshipsNameSpace(workbookMarshal string) string {
return workbookMarshal
}
// Check XML tags and fix discontinuous case, for example:
// Check XML tags and fix discontinuous case. For example:
//
// <row r="15" spans="1:22" x14ac:dyDescent="0.2">
// <c r="A15" s="2" />
......@@ -232,7 +234,8 @@ func replaceWorkSheetsRelationshipsNameSpace(workbookMarshal string) string {
// <c r="G15" s="1" />
// </row>
//
// Noteice: this method could be very slow for large spreadsheets (more than 3000 rows one sheet).
// Noteice: this method could be very slow for large spreadsheets (more than
// 3000 rows one sheet).
func checkRow(xlsx xlsxWorksheet) xlsxWorksheet {
buffer := bytes.Buffer{}
for k, v := range xlsx.SheetData.Row {
......@@ -267,7 +270,8 @@ func checkRow(xlsx xlsxWorksheet) xlsxWorksheet {
// UpdateLinkedValue fix linked values within a spreadsheet are not updating in
// Office Excel 2007 and 2010. This function will be remove value tag when met a
// cell have a linked value. Reference https://social.technet.microsoft.com/Forums/office/en-US/e16bae1f-6a2c-4325-8013-e989a3479066/excel-2010-linked-cells-not-updating?forum=excel
// cell have a linked value. Reference
// https://social.technet.microsoft.com/Forums/office/en-US/e16bae1f-6a2c-4325-8013-e989a3479066/excel-2010-linked-cells-not-updating?forum=excel
//
// Notice: after open XLSX file Excel will be update linked value and generate
// new value and will prompt save file or not.
......
......@@ -112,10 +112,12 @@ func TestOpenFile(t *testing.T) {
if err != nil {
t.Log(err)
}
}
func TestBrokenFile(t *testing.T) {
// Test write file with broken file struct.
f2 := File{}
err = f2.Save()
err := f2.Save()
if err != nil {
t.Log(err)
}
......@@ -124,41 +126,39 @@ func TestOpenFile(t *testing.T) {
if err != nil {
t.Log(err)
}
}
func TestCreateFile(t *testing.T) {
// Test create a XLSX file.
f3 := CreateFile()
f3.NewSheet(2, "XLSXSheet2")
f3.NewSheet(3, "XLSXSheet3")
f3.SetCellInt("Sheet2", "A23", 56)
f3.SetCellStr("SHEET1", "B20", "42")
f3.SetActiveSheet(0)
// Test add picture to sheet.
err := f3.AddPicture("Sheet1", "H2", "K12", "./test/images/excel.gif")
// Test set active sheet without BookViews and Sheets maps in xl/workbook.xml.
f3, err := OpenFile("./test/badWorkbook.xlsx")
f3.SetActiveSheet(2)
if err != nil {
t.Log(err)
}
err = f3.AddPicture("Sheet1", "C2", "F12", "./test/images/excel.tif")
// Test open a XLSX file with given illegal path.
_, err = OpenFile("./test/Workbook.xlsx")
if err != nil {
t.Log(err)
}
err = f3.WriteTo("./test/Workbook_3.xlsx")
}
func TestCreateFile(t *testing.T) {
// Test create a XLSX file.
f4 := CreateFile()
f4.NewSheet(2, "XLSXSheet2")
f4.NewSheet(3, "XLSXSheet3")
f4.SetCellInt("Sheet2", "A23", 56)
f4.SetCellStr("SHEET1", "B20", "42")
f4.SetActiveSheet(0)
// Test add picture to sheet.
err := f4.AddPicture("Sheet1", "H2", "K12", "./test/images/excel.gif")
if err != nil {
t.Log(err)
}
}
func TestBrokenFile(t *testing.T) {
// Test set active sheet without BookViews and Sheets maps in xl/workbook.xml.
f4, err := OpenFile("./test/badWorkbook.xlsx")
f4.SetActiveSheet(2)
err = f4.AddPicture("Sheet1", "C2", "F12", "./test/images/excel.tif")
if err != nil {
t.Log(err)
}
// Test open a XLSX file with given illegal path.
_, err = OpenFile("./test/Workbook.xlsx")
err = f4.WriteTo("./test/Workbook_3.xlsx")
if err != nil {
t.Log(err)
}
......
......@@ -6,9 +6,11 @@ import (
"os"
)
// CreateFile provide function to create new file by default template.
// For example:
// xlsx := CreateFile()
// CreateFile provides function to create new file by default template. For
// example:
//
// xlsx := CreateFile()
//
func CreateFile() *File {
file := make(map[string]string)
file["_rels/.rels"] = templateRels
......@@ -25,7 +27,7 @@ func CreateFile() *File {
}
}
// Save provide function override the xlsx file with origin path.
// Save provides function override the xlsx file with origin path.
func (f *File) Save() error {
buf := new(bytes.Buffer)
w := zip.NewWriter(buf)
......@@ -51,7 +53,8 @@ func (f *File) Save() error {
return err
}
// WriteTo provide function create or update to an xlsx file at the provided path.
// WriteTo provides function to create or update to an xlsx file at the provided
// path.
func (f *File) WriteTo(name string) error {
buf := new(bytes.Buffer)
w := zip.NewWriter(buf)
......
......@@ -9,16 +9,16 @@ import (
"math"
)
// ReadZip takes a pointer to a zip.ReadCloser and returns a
// xlsx.File struct populated with its contents. In most cases
// ReadZip is not used directly, but is called internally by OpenFile.
// ReadZip takes a pointer to a zip.ReadCloser and returns a xlsx.File struct
// populated with its contents. In most cases ReadZip is not used directly, but
// is called internally by OpenFile.
func ReadZip(f *zip.ReadCloser) (map[string]string, int, error) {
defer f.Close()
return ReadZipReader(&f.Reader)
}
// ReadZipReader can be used to read an XLSX in memory without
// touching the filesystem.
// ReadZipReader can be used to read an XLSX in memory without touching the
// filesystem.
func ReadZipReader(r *zip.Reader) (map[string]string, int, error) {
fileList := make(map[string]string)
worksheets := 0
......@@ -88,8 +88,8 @@ func titleToNumber(s string) int {
return sum - 1
}
// letterOnlyMapF is used in conjunction with strings.Map to return
// only the characters A-Z and a-z in a string.
// letterOnlyMapF is used in conjunction with strings.Map to return only the
// characters A-Z and a-z in a string.
func letterOnlyMapF(rune rune) rune {
switch {
case 'A' <= rune && rune <= 'Z':
......@@ -100,8 +100,8 @@ func letterOnlyMapF(rune rune) rune {
return -1
}
// intOnlyMapF is used in conjunction with strings.Map to return only
// the numeric portions of a string.
// intOnlyMapF is used in conjunction with strings.Map to return only the
// numeric portions of a string.
func intOnlyMapF(rune rune) rune {
if rune >= 48 && rune < 58 {
return rune
......
......@@ -13,8 +13,8 @@ import (
"strings"
)
// AddPicture provide the method to add picture in a sheet by given xAxis, yAxis and file path.
// For example:
// AddPicture provide the method to add picture in a sheet by given xAxis, yAxis
// and file path. For example:
//
// xlsx := excelize.CreateFile()
// err := xlsx.AddPicture("Sheet1", "A2", "H9", "./image.jpg")
......@@ -63,8 +63,9 @@ func (f *File) AddPicture(sheet string, xAxis string, yAxis string, picture stri
return err
}
// addSheetRelationships provides function to add xl/worksheets/_rels/sheet%d.xml.rels by given
// sheet name, relationship type and target.
// addSheetRelationships provides function to add
// xl/worksheets/_rels/sheet%d.xml.rels by given sheet name, relationship type
// and target.
func (f *File) addSheetRelationships(sheet string, relType string, target string) int {
var rels = "xl/worksheets/_rels/" + strings.ToLower(sheet) + ".xml.rels"
var sheetRels xlsxWorkbookRels
......@@ -93,8 +94,8 @@ func (f *File) addSheetRelationships(sheet string, relType string, target string
return rID
}
// addSheetDrawing provides function to add drawing element to xl/worksheets/sheet%d.xml by
// given sheet name and relationship index.
// addSheetDrawing provides function to add drawing element to
// xl/worksheets/sheet%d.xml by given sheet name and relationship index.
func (f *File) addSheetDrawing(sheet string, rID int) {
var xlsx xlsxWorksheet
name := "xl/worksheets/" + strings.ToLower(sheet) + ".xml"
......@@ -109,7 +110,8 @@ func (f *File) addSheetDrawing(sheet string, rID int) {
f.saveFileList(name, string(output))
}
// countDrawings provides function to get drawing files count storage in the folder xl/drawings.
// countDrawings provides function to get drawing files count storage in the
// folder xl/drawings.
func (f *File) countDrawings() int {
count := 0
for k := range f.XLSX {
......@@ -120,10 +122,10 @@ func (f *File) countDrawings() int {
return count
}
// addDrawing provides function to add picture by given drawingXML, xAxis, yAxis, file name
// and relationship index. In order to solve the problem that the label structure is changed
// after serialization and deserialization, two different structures: decodeWsDr and encodeWsDr
// are defined.
// addDrawing provides function to add picture by given drawingXML, xAxis,
// yAxis, file name and relationship index. In order to solve the problem that
// the label structure is changed after serialization and deserialization, two
// different structures: decodeWsDr and encodeWsDr are defined.
func (f *File) addDrawing(drawingXML string, xAxis string, yAxis string, file string, rID int) {
xAxis = strings.ToUpper(xAxis)
fromCol := string(strings.Map(letterOnlyMapF, xAxis))
......@@ -186,8 +188,9 @@ func (f *File) addDrawing(drawingXML string, xAxis string, yAxis string, file st
f.saveFileList(drawingXML, result)
}
// addDrawingRelationships provides function to add image part relationships in the file
// xl/drawings/_rels/drawing%d.xml.rels by given drawing index, relationship type and target.
// addDrawingRelationships provides function to add image part relationships in
// the file xl/drawings/_rels/drawing%d.xml.rels by given drawing index,
// relationship type and target.
func (f *File) addDrawingRelationships(index int, relType string, target string) int {
var rels = "xl/drawings/_rels/drawing" + strconv.Itoa(index) + ".xml.rels"
var drawingRels xlsxWorkbookRels
......@@ -216,7 +219,8 @@ func (f *File) addDrawingRelationships(index int, relType string, target string)
return rID
}
// countMedia provides function to get media files count storage in the folder xl/media/image.
// countMedia provides function to get media files count storage in the folder
// xl/media/image.
func (f *File) countMedia() int {
count := 0
for k := range f.XLSX {
......@@ -227,8 +231,8 @@ func (f *File) countMedia() int {
return count
}
// addMedia provides function to add picture into folder xl/media/image by given file
// name and extension name.
// addMedia provides function to add picture into folder xl/media/image by given
// file name and extension name.
func (f *File) addMedia(file string, ext string) {
count := f.countMedia()
dat, _ := ioutil.ReadFile(file)
......@@ -236,8 +240,9 @@ func (f *File) addMedia(file string, ext string) {
f.XLSX[media] = string(dat)
}
// addDrawingContentTypePart provides function to add image part relationships in
// http://purl.oclc.org/ooxml/officeDocument/relationships/image and appropriate content type.
// addDrawingContentTypePart provides function to add image part relationships
// in http://purl.oclc.org/ooxml/officeDocument/relationships/image and
// appropriate content type.
func (f *File) addDrawingContentTypePart(index int) {
var imageTypes = map[string]bool{"jpeg": false, "png": false, "gif": false, "tiff": false}
var content xlsxTypes
......@@ -271,8 +276,9 @@ func (f *File) addDrawingContentTypePart(index int) {
f.saveFileList(`[Content_Types].xml`, string(output))
}
// getSheetRelationshipsTargetByID provides function to get Target attribute value
// in xl/worksheets/_rels/sheet%d.xml.rels by given sheet name and relationship index.
// getSheetRelationshipsTargetByID provides function to get Target attribute
// value in xl/worksheets/_rels/sheet%d.xml.rels by given sheet name and
// relationship index.
func (f *File) getSheetRelationshipsTargetByID(sheet string, rID string) string {
var rels = "xl/worksheets/_rels/" + strings.ToLower(sheet) + ".xml.rels"
var sheetRels xlsxWorkbookRels
......
......@@ -43,9 +43,8 @@ func readXMLSST(f *File) (xlsxSST, error) {
return shardStrings, err
}
// getValueFrom return a value from a column/row cell,
// this function is inteded to be used with for range on rows
// an argument with the xlsx opened file.
// getValueFrom return a value from a column/row cell, this function is inteded
// to be used with for range on rows an argument with the xlsx opened file.
func (xlsx *xlsxC) getValueFrom(f *File) (string, error) {
switch xlsx.T {
case "s":
......
......@@ -8,9 +8,10 @@ import (
"strings"
)
// NewSheet provice function to greate a new sheet by given index, when
// creating a new XLSX file, the default sheet will be create, when you
// create a new file, you need to ensure that the index is continuous.
// Sprint formats using the default formats for its operands and returns the
// resulting string. NewSheet provice function to greate a new sheet by given
// index, when creating a new XLSX file, the default sheet will be create, when
// you create a new file, you need to ensure that the index is continuous.
func (f *File) NewSheet(index int, name string) {
// Update docProps/app.xml
f.setAppXML()
......@@ -54,7 +55,8 @@ func (f *File) setSheet(index int) {
f.saveFileList(path, replaceWorkSheetsRelationshipsNameSpace(string(output)))
}
// Update workbook property of XLSX. Maximum 31 characters are allowed in sheet title.
// setWorkbook update workbook property of XLSX. Maximum 31 characters are
// allowed in sheet title.
func (f *File) setWorkbook(name string, rid int) {
var content xlsxWorkbook
r := strings.NewReplacer(":", "", "\\", "", "/", "", "?", "", "*", "", "[", "", "]", "")
......@@ -75,14 +77,14 @@ func (f *File) setWorkbook(name string, rid int) {
f.saveFileList("xl/workbook.xml", replaceRelationshipsNameSpace(string(output)))
}
// Read and unmarshal workbook relationships of XLSX.
// readXlsxWorkbookRels read and unmarshal workbook relationships of XLSX file.
func (f *File) readXlsxWorkbookRels() xlsxWorkbookRels {
var content xlsxWorkbookRels
xml.Unmarshal([]byte(f.readXML("xl/_rels/workbook.xml.rels")), &content)
return content
}
// Update workbook relationships property of XLSX.
// addXlsxWorkbookRels update workbook relationships property of XLSX.
func (f *File) addXlsxWorkbookRels(sheet int) int {
content := f.readXlsxWorkbookRels()
rID := len(content.Relationships) + 1
......@@ -106,25 +108,26 @@ func (f *File) addXlsxWorkbookRels(sheet int) int {
return rID
}
// Update docProps/app.xml file of XML.
// setAppXML update docProps/app.xml file of XML.
func (f *File) setAppXML() {
f.saveFileList("docProps/app.xml", templateDocpropsApp)
}
// Some tools that read XLSX files have very strict requirements about
// the structure of the input XML. In particular both Numbers on the Mac
// and SAS dislike inline XML namespace declarations, or namespace
// prefixes that don't match the ones that Excel itself uses. This is a
// problem because the Go XML library doesn't multiple namespace
// declarations in a single element of a document. This function is a
// horrible hack to fix that after the XML marshalling is completed.
// Some tools that read XLSX files have very strict requirements about the
// structure of the input XML. In particular both Numbers on the Mac and SAS
// dislike inline XML namespace declarations, or namespace prefixes that don't
// match the ones that Excel itself uses. This is a problem because the Go XML
// library doesn't multiple namespace declarations in a single element of a
// document. This function is a horrible hack to fix that after the XML
// marshalling is completed.
func replaceRelationshipsNameSpace(workbookMarshal string) string {
oldXmlns := `<workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">`
newXmlns := `<workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x15" xmlns:x15="http://schemas.microsoft.com/office/spreadsheetml/2010/11/main">`
return strings.Replace(workbookMarshal, oldXmlns, newXmlns, -1)
}
// SetActiveSheet provide function to set default active sheet of XLSX by given index.
// SetActiveSheet provide function to set default active sheet of XLSX by given
// index.
func (f *File) SetActiveSheet(index int) {
var content xlsxWorkbook
if index < 1 {
......@@ -177,8 +180,8 @@ func (f *File) SetActiveSheet(index int) {
return
}
// GetActiveSheetIndex provides function to get active sheet of XLSX. If not found
// the active sheet will be return integer 0.
// GetActiveSheetIndex provides function to get active sheet of XLSX. If not
// found the active sheet will be return integer 0.
func (f *File) GetActiveSheetIndex() int {
content := xlsxWorkbook{}
buffer := bytes.Buffer{}
......@@ -200,10 +203,11 @@ func (f *File) GetActiveSheetIndex() int {
return 0
}
// SetSheetName provides function to set the sheet name be given old and new sheet name.
// Maximum 31 characters are allowed in sheet title and this function only changes the
// name of the sheet and will not update the sheet name in the formula or reference
// associated with the cell. So there may be problem formula error or reference missing.
// SetSheetName provides function to set the sheet name be given old and new
// sheet name. Maximum 31 characters are allowed in sheet title and this
// function only changes the name of the sheet and will not update the sheet
// name in the formula or reference associated with the cell. So there may be
// problem formula error or reference missing.
func (f *File) SetSheetName(oldName, newName string) {
var content = xlsxWorkbook{}
r := strings.NewReplacer(":", "", "\\", "", "/", "", "?", "", "*", "", "[", "", "]", "")
......@@ -221,8 +225,8 @@ func (f *File) SetSheetName(oldName, newName string) {
f.saveFileList("xl/workbook.xml", replaceRelationshipsNameSpace(string(output)))
}
// GetSheetName provides function to get sheet name of XLSX by given sheet index.
// If given sheet index is invalid, will return an empty string.
// GetSheetName provides function to get sheet name of XLSX by given sheet
// index. If given sheet index is invalid, will return an empty string.
func (f *File) GetSheetName(index int) string {
var content = xlsxWorkbook{}
xml.Unmarshal([]byte(f.readXML("xl/workbook.xml")), &content)
......
......@@ -2,17 +2,19 @@ package excelize
import "encoding/xml"
// decodeTwoCellAnchor directly maps the twoCellAnchor (Two Cell Anchor Shape Size). This element
// specifies a two cell anchor placeholder for a group, a shape, or a drawing element. It moves
// with cells and its extents are in EMU units.
// decodeTwoCellAnchor directly maps the twoCellAnchor (Two Cell Anchor Shape
// Size). This element specifies a two cell anchor placeholder for a group, a
// shape, or a drawing element. It moves with cells and its extents are in EMU
// units.
type decodeTwoCellAnchor struct {
EditAs string `xml:"editAs,attr,omitempty"`
Content string `xml:",innerxml"`
}
// decodeWsDr directly maps the root element for a part of this content type shall wsDr.
// In order to solve the problem that the label structure is changed after serialization
// and deserialization, two different structures are defined. decodeWsDr just for deserialization.
// decodeWsDr directly maps the root element for a part of this content type
// shall wsDr. In order to solve the problem that the label structure is changed
// after serialization and deserialization, two different structures are
// defined. decodeWsDr just for deserialization.
type decodeWsDr struct {
A string `xml:"xmlns a,attr"`
Xdr string `xml:"xmlns xdr,attr"`
......
......@@ -10,10 +10,9 @@ const (
NameSpaceSpreadSheetDrawing = "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing"
)
// xlsxCNvPr directly maps the cNvPr (Non-Visual Drawing Properties).
// This element specifies non-visual canvas properties. This allows for
// additional information that does not affect the appearance of the
// picture to be stored.
// xlsxCNvPr directly maps the cNvPr (Non-Visual Drawing Properties). This
// element specifies non-visual canvas properties. This allows for additional
// information that does not affect the appearance of the picture to be stored.
type xlsxCNvPr struct {
ID int `xml:"id,attr"`
Name string `xml:"name,attr"`
......@@ -22,9 +21,9 @@ type xlsxCNvPr struct {
}
// xlsxPicLocks directly maps the picLocks (Picture Locks). This element
// specifies all locking properties for a graphic frame. These properties
// inform the generating application about specific properties that have
// been previously locked and thus should not be changed.
// specifies all locking properties for a graphic frame. These properties inform
// the generating application about specific properties that have been
// previously locked and thus should not be changed.
type xlsxPicLocks struct {
NoAdjustHandles bool `xml:"noAdjustHandles,attr,omitempty"`
NoChangeArrowheads bool `xml:"noChangeArrowheads,attr,omitempty"`
......@@ -39,25 +38,25 @@ type xlsxPicLocks struct {
NoSelect bool `xml:"noSelect,attr,omitempty"`
}
// xlsxBlip directly maps the blip element in the namespace
// http://purl.oclc.or g/ooxml/officeDoc ument/relationships -
// This element specifies the existence of an image (binary large image or
// picture) and contains a reference to the image data.
// xlsxBlip directly maps the blip element in the namespace http://purl.oclc.or
// g/ooxml/officeDoc ument/relationships - This element specifies the existence
// of an image (binary large image or picture) and contains a reference to the
// image data.
type xlsxBlip struct {
Embed string `xml:"r:embed,attr"`
Cstate string `xml:"cstate,attr,omitempty"`
R string `xml:"xmlns:r,attr"`
}
// xlsxStretch directly maps the stretch element. This element specifies
// that a BLIP should be stretched to fill the target rectangle. The other
// option is a tile where a BLIP is tiled to fill the available area.
// xlsxStretch directly maps the stretch element. This element specifies that a
// BLIP should be stretched to fill the target rectangle. The other option is a
// tile where a BLIP is tiled to fill the available area.
type xlsxStretch struct {
FillRect string `xml:"a:fillRect"`
}
// xlsxOff directly maps the colOff and rowOff element. This element is used
// to specify the column offset within a cell.
// xlsxOff directly maps the colOff and rowOff element. This element is used to
// specify the column offset within a cell.
type xlsxOff struct {
X int `xml:"x,attr"`
Y int `xml:"y,attr"`
......@@ -69,61 +68,65 @@ type xlsxExt struct {
Cy int `xml:"cy,attr"`
}
// xlsxPrstGeom directly maps the prstGeom (Preset geometry). This element specifies
// when a preset geometric shape should be used instead of a custom geometric shape.
// The generating application should be able to render all preset geometries enumerated
// in the ST_ShapeType list.
// xlsxPrstGeom directly maps the prstGeom (Preset geometry). This element
// specifies when a preset geometric shape should be used instead of a custom
// geometric shape. The generating application should be able to render all
// preset geometries enumerated in the ST_ShapeType list.
type xlsxPrstGeom struct {
Prst string `xml:"prst,attr"`
}
// xlsxXfrm directly maps the xfrm (2D Transform for Graphic Frame). This element
// specifies the transform to be applied to the corresponding graphic frame. This
// transformation is applied to the graphic frame just as it would be for a shape
// or group shape.
// xlsxXfrm directly maps the xfrm (2D Transform for Graphic Frame). This
// element specifies the transform to be applied to the corresponding graphic
// frame. This transformation is applied to the graphic frame just as it would
// be for a shape or group shape.
type xlsxXfrm struct {
Off xlsxOff `xml:"a:off"`
Ext xlsxExt `xml:"a:ext"`
}
// xlsxCNvPicPr directly maps the cNvPicPr (Non-Visual Picture Drawing Properties).
// This element specifies the non-visual properties for the picture canvas. These
// properties are to be used by the generating application to determine how certain
// properties are to be changed for the picture object in question.
// xlsxCNvPicPr directly maps the cNvPicPr (Non-Visual Picture Drawing
// Properties). This element specifies the non-visual properties for the picture
// canvas. These properties are to be used by the generating application to
// determine how certain properties are to be changed for the picture object in
// question.
type xlsxCNvPicPr struct {
PicLocks xlsxPicLocks `xml:"a:picLocks"`
}
// directly maps the nvPicPr (Non-Visual Properties for a Picture). This element specifies
// all non-visual properties for a picture. This element is a container for the non-visual
// identification properties, shape properties and application properties that are to be
// associated with a picture. This allows for additional information that does not affect
// the appearance of the picture to be stored.
// directly maps the nvPicPr (Non-Visual Properties for a Picture). This element
// specifies all non-visual properties for a picture. This element is a
// container for the non-visual identification properties, shape properties and
// application properties that are to be associated with a picture. This allows
// for additional information that does not affect the appearance of the picture
// to be stored.
type xlsxNvPicPr struct {
CNvPr xlsxCNvPr `xml:"xdr:cNvPr"`
CNvPicPr xlsxCNvPicPr `xml:"xdr:cNvPicPr"`
}
// xlsxBlipFill directly maps the blipFill (Picture Fill). This element specifies the kind
// of picture fill that the picture object has. Because a picture has a picture fill already
// by default, it is possible to have two fills specified for a picture object.
// xlsxBlipFill directly maps the blipFill (Picture Fill). This element
// specifies the kind of picture fill that the picture object has. Because a
// picture has a picture fill already by default, it is possible to have two
// fills specified for a picture object.
type xlsxBlipFill struct {
Blip xlsxBlip `xml:"a:blip"`
Stretch xlsxStretch `xml:"a:stretch"`
}
// xlsxSpPr directly maps the spPr (Shape Properties). This element specifies the visual shape
// properties that can be applied to a picture. These are the same properties that are allowed
// to describe the visual properties of a shape but are used here to describe the visual
// appearance of a picture within a document.
// xlsxSpPr directly maps the spPr (Shape Properties). This element specifies the visual
// shape properties that can be applied to a picture. These are the same properties that
// are allowed to describe the visual properties of a shape but are used here to describe
// the visual appearance of a picture within a document.
type xlsxSpPr struct {
Xfrm xlsxXfrm `xml:"a:xfrm"`
PrstGeom xlsxPrstGeom `xml:"a:prstGeom"`
}
// xlsxPic elements encompass the definition of pictures within the DrawingML framework. While
// pictures are in many ways very similar to shapes they have specific properties that are unique
// in order to optimize for picture- specific scenarios.
// xlsxPic elements encompass the definition of pictures within the DrawingML
// framework. While pictures are in many ways very similar to shapes they have
// specific properties that are unique in order to optimize for picture-
// specific scenarios.
type xlsxPic struct {
NvPicPr xlsxNvPicPr `xml:"xdr:nvPicPr"`
BlipFill xlsxBlipFill `xml:"xdr:blipFill"`
......@@ -146,19 +149,21 @@ type xlsxTo struct {
RowOff int `xml:"xdr:rowOff"`
}
// xlsxClientData directly maps the clientData element. An empty element which specifies (via
// attributes) certain properties related to printing and selection of the drawing object. The
// fLocksWithSheet attribute (either true or false) determines whether to disable selection when
// the sheet is protected, and fPrintsWithSheet attribute (either true or false) determines whether
// the object is printed when the sheet is printed.
// xlsxClientData directly maps the clientData element. An empty element which
// specifies (via attributes) certain properties related to printing and
// selection of the drawing object. The fLocksWithSheet attribute (either true
// or false) determines whether to disable selection when the sheet is
// protected, and fPrintsWithSheet attribute (either true or false) determines
// whether the object is printed when the sheet is printed.
type xlsxClientData struct {
FLocksWithSheet bool `xml:"fLocksWithSheet,attr"`
FPrintsWithSheet bool `xml:"fPrintsWithSheet,attr"`
}
// xlsxTwoCellAnchor directly maps the twoCellAnchor (Two Cell Anchor Shape Size). This element
// specifies a two cell anchor placeholder for a group, a shape, or a drawing element. It moves
// with cells and its extents are in EMU units.
// xlsxTwoCellAnchor directly maps the twoCellAnchor (Two Cell Anchor Shape
// Size). This element specifies a two cell anchor placeholder for a group, a
// shape, or a drawing element. It moves with cells and its extents are in EMU
// units.
type xlsxTwoCellAnchor struct {
EditAs string `xml:"editAs,attr,omitempty"`
From *xlsxFrom `xml:"xdr:from"`
......@@ -168,7 +173,8 @@ type xlsxTwoCellAnchor struct {
ClientData *xlsxClientData `xml:"xdr:clientData"`
}
// xlsxWsDr directly maps the root element for a part of this content type shall wsDr.
// xlsxWsDr directly maps the root element for a part of this content type shall
// wsDr.
type xlsxWsDr struct {
TwoCellAnchor []*xlsxTwoCellAnchor `xml:"xdr:twoCellAnchor"`
Xdr string `xml:"xmlns:xdr,attr"`
......
......@@ -3,8 +3,8 @@ package excelize
import "encoding/xml"
// xlsxSST directly maps the sst element from the namespace
// http://schemas.openxmlformats.org/spreadsheetml/2006/main currently
// I have not checked this for completeness - it does as much as I need.
// http://schemas.openxmlformats.org/spreadsheetml/2006/main currently I have
// not checked this for completeness - it does as much as I need.
type xlsxSST struct {
XMLName xml.Name `xml:"http://schemas.openxmlformats.org/spreadsheetml/2006/main sst"`
Count int `xml:"count,attr"`
......@@ -13,18 +13,16 @@ type xlsxSST struct {
}
// xlsxSI directly maps the si element from the namespace
// http://schemas.openxmlformats.org/spreadsheetml/2006/main -
// currently I have not checked this for completeness - it does as
// much as I need.
// http://schemas.openxmlformats.org/spreadsheetml/2006/main - currently I have
// not checked this for completeness - it does as much as I need.
type xlsxSI struct {
T string `xml:"t"`
R []xlsxR `xml:"r"`
}
// xlsxR directly maps the r element from the namespace
// http://schemas.openxmlformats.org/spreadsheetml/2006/main -
// currently I have not checked this for completeness - it does as
// much as I need.
// http://schemas.openxmlformats.org/spreadsheetml/2006/main - currently I have
// not checked this for completeness - it does as much as I need.
type xlsxR struct {
T string `xml:"t"`
}
......@@ -10,8 +10,7 @@ const (
sheetStateVeryHidden = `veryHidden`
)
// xmlxWorkbookRels contains xmlxWorkbookRelations
// which maps sheet id and sheet XML.
// xmlxWorkbookRels contains xmlxWorkbookRelations which maps sheet id and sheet XML.
type xlsxWorkbookRels struct {
XMLName xml.Name `xml:"http://schemas.openxmlformats.org/package/2006/relationships Relationships"`
Relationships []xlsxWorkbookRelation `xml:"Relationship"`
......@@ -25,9 +24,8 @@ type xlsxWorkbookRelation struct {
}
// 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.
// http://schemas.openxmlformats.org/spreadsheetml/2006/main - currently I have
// not checked it for completeness - it does as much as I need.
type xlsxWorkbook struct {
XMLName xml.Name `xml:"http://schemas.openxmlformats.org/spreadsheetml/2006/main workbook"`
FileVersion *xlsxFileVersion `xml:"fileVersion"`
......@@ -43,10 +41,10 @@ type xlsxWorkbook struct {
FileRecoveryPr *xlsxFileRecoveryPr `xml:"fileRecoveryPr"`
}
// xlsxFileRecoveryPr maps sheet recovery information. This element
// defines properties that track the state of the workbook file, such
// as whether the file was saved during a crash, or whether it should
// be opened in auto-recover mode.
// xlsxFileRecoveryPr maps sheet recovery information. This element defines
// properties that track the state of the workbook file, such as whether the
// file was saved during a crash, or whether it should be opened in auto-recover
// mode.
type xlsxFileRecoveryPr struct {
AutoRecover bool `xml:"autoRecover,attr,omitempty"`
CrashSave bool `xml:"crashSave,attr,omitempty"`
......@@ -54,16 +52,15 @@ type xlsxFileRecoveryPr struct {
RepairLoad bool `xml:"repairLoad,attr,omitempty"`
}
// xlsxWorkbookProtection directly maps the workbookProtection element.
// This element specifies options for protecting data in the workbook.
// Applications might use workbook protection to prevent anyone from
// accidentally changing, moving, or deleting important data. This
// protection can be ignored by applications which choose not to support
// this optional protection mechanism.
// When a password is to be hashed and stored in this element, it shall
// be hashed as defined below, starting from a UTF-16LE encoded string
// value. If there is a leading BOM character (U+FEFF) in the encoded
// password it is removed before hash calculation.
// xlsxWorkbookProtection directly maps the workbookProtection element. This
// element specifies options for protecting data in the workbook. Applications
// might use workbook protection to prevent anyone from accidentally changing,
// moving, or deleting important data. This protection can be ignored by
// applications which choose not to support this optional protection mechanism.
// When a password is to be hashed and stored in this element, it shall be
// hashed as defined below, starting from a UTF-16LE encoded string value. If
// there is a leading BOM character (U+FEFF) in the encoded password it is
// removed before hash calculation.
type xlsxWorkbookProtection struct {
LockRevision bool `xml:"lockRevision,attr,omitempty"`
LockStructure bool `xml:"lockStructure,attr,omitempty"`
......@@ -78,9 +75,9 @@ type xlsxWorkbookProtection struct {
WorkbookSpinCount int `xml:"workbookSpinCount,attr,omitempty"`
}
// xlsxFileVersion directly maps the fileVersion element. This element
// defines properties that track which version of the application accessed
// the data and source code contained in the file.
// xlsxFileVersion directly maps the fileVersion element. This element defines
// properties that track which version of the application accessed the data and
// source code contained in the file.
type xlsxFileVersion struct {
AppName string `xml:"appName,attr,omitempty"`
CodeName string `xml:"codeName,attr,omitempty"`
......@@ -89,9 +86,9 @@ type xlsxFileVersion struct {
RupBuild string `xml:"rupBuild,attr,omitempty"`
}
// xlsxWorkbookPr directly maps the workbookPr element from the
// namespace http://schemas.openxmlformats.org/spreadsheetml/2006/main
// This element defines a collection of workbook properties.
// xlsxWorkbookPr directly maps the workbookPr element from the namespace
// http://schemas.openxmlformats.org/spreadsheetml/2006/main This element
// defines a collection of workbook properties.
type xlsxWorkbookPr struct {
AllowRefreshQuery bool `xml:"allowRefreshQuery,attr,omitempty"`
AutoCompressPictures bool `xml:"autoCompressPictures,attr,omitempty"`
......@@ -113,17 +110,17 @@ type xlsxWorkbookPr struct {
UpdateLinks string `xml:"updateLinks,attr,omitempty"`
}
// xlsxBookViews directly maps the bookViews element. This element specifies
// the collection of workbook views of the enclosing workbook. Each view can
// specify a window position, filter options, and other configurations. There
// is no limit on the number of workbook views that can be defined for a workbook.
// xlsxBookViews directly maps the bookViews element. This element specifies the
// collection of workbook views of the enclosing workbook. Each view can specify
// a window position, filter options, and other configurations. There is no
// limit on the number of workbook views that can be defined for a workbook.
type xlsxBookViews struct {
WorkBookView []xlsxWorkBookView `xml:"workbookView"`
}
// xlsxWorkBookView directly maps the workbookView element from the
// namespace http://schemas.openxmlformats.org/spreadsheetml/2006/main
// This element specifies a single Workbook view.
// xlsxWorkBookView directly maps the workbookView element from the namespace
// http://schemas.openxmlformats.org/spreadsheetml/2006/main This element
// specifies a single Workbook view.
type xlsxWorkBookView struct {
ActiveTab int `xml:"activeTab,attr,omitempty"`
AutoFilterDateGrouping bool `xml:"autoFilterDateGrouping,attr,omitempty"`
......@@ -147,9 +144,8 @@ type xlsxSheets struct {
}
// xlsxSheet directly maps the sheet 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.
// http://schemas.openxmlformats.org/spreadsheetml/2006/main - currently I have
// not checked it for completeness - it does as much as I need.
type xlsxSheet struct {
Name string `xml:"name,attr,omitempty"`
SheetID string `xml:"sheetId,attr,omitempty"`
......@@ -157,20 +153,20 @@ type xlsxSheet struct {
State string `xml:"state,attr,omitempty"`
}
// xlsxExternalReferences directly maps the externalReferences element
// of the external workbook references part.
// xlsxExternalReferences directly maps the externalReferences element of the
// external workbook references part.
type xlsxExternalReferences struct {
ExternalReference []xlsxExternalReference `xml:"externalReference"`
}
// xlsxExternalReference directly maps the externalReference element
// of the external workbook references part.
// xlsxExternalReference directly maps the externalReference element of the
// external workbook references part.
type xlsxExternalReference struct {
RID string `xml:"http://schemas.openxmlformats.org/officeDocument/2006/relationships id,attr,omitempty"`
}
// xlsxPivotCaches element enumerates pivot cache definition parts
// used by pivot tables and formulas in this workbook.
// xlsxPivotCaches element enumerates pivot cache definition parts used by pivot
// tables and formulas in this workbook.
type xlsxPivotCaches struct {
PivotCache []xlsxPivotCache `xml:"pivotCache"`
}
......@@ -182,33 +178,30 @@ type xlsxPivotCache struct {
}
// extLst element provides a convention for extending spreadsheetML in
// predefined locations. The locations shall be denoted with the extLst
// element, and are called extension lists. Extension list locations
// within the markup document are specified in the markup specification
// and can be used to store extensions to the markup specification,
// whether those are future version extensions of the markup specification
// or are private extensions implemented independently from the markup
// specification. Markup within an extension might not be understood by a
// consumer.
// predefined locations. The locations shall be denoted with the extLst element,
// and are called extension lists. Extension list locations within the markup
// document are specified in the markup specification and can be used to store
// extensions to the markup specification, whether those are future version
// extensions of the markup specification or are private extensions implemented
// independently from the markup specification. Markup within an extension might
// not be understood by a consumer.
type xlsxExtLst struct {
Ext string `xml:",innerxml"`
}
// xlsxDefinedNames directly maps the definedNames element. This element
// defines the collection of defined names for this workbook. Defined
// names are descriptive names to represent cells, ranges of cells,
// formulas, or constant values. Defined names can be used to represent
// a range on any worksheet.
// xlsxDefinedNames directly maps the definedNames element. This element defines
// the collection of defined names for this workbook. Defined names are
// descriptive names to represent cells, ranges of cells, formulas, or constant
// values. Defined names can be used to represent a range on any worksheet.
type xlsxDefinedNames struct {
DefinedName []xlsxDefinedName `xml:"definedName"`
}
// xlsxDefinedName directly maps the definedName element from the
// namespace http://schemas.openxmlformats.org/spreadsheetml/2006/main
// This element defines a defined name within this workbook. A defined
// name is descriptive text that is used to represents a cell, range of
// cells, formula, or constant value. For a descriptions of the attributes
// see https://msdn.microsoft.com/en-us/library/office/documentformat.openxml.spreadsheet.definedname.aspx
// xlsxDefinedName directly maps the definedName element from the namespace
// http://schemas.openxmlformats.org/spreadsheetml/2006/main This element
// defines a defined name within this workbook. A defined name is descriptive
// text that is used to represents a cell, range of cells, formula, or constant
// value. For a descriptions of the attributes see https://msdn.microsoft.com/en-us/library/office/documentformat.openxml.spreadsheet.definedname.aspx
type xlsxDefinedName struct {
Comment string `xml:"comment,attr,omitempty"`
CustomMenu string `xml:"customMenu,attr,omitempty"`
......@@ -229,10 +222,9 @@ type xlsxDefinedName struct {
}
// xlsxCalcPr directly maps the calcPr element. This element defines the
// collection of properties the application uses to record calculation
// status and details. Calculation is the process of computing formulas
// and then displaying the results as values in the cells that contain
// the formulas.
// collection of properties the application uses to record calculation status
// and details. Calculation is the process of computing formulas and then
// displaying the results as values in the cells that contain the formulas.
type xlsxCalcPr struct {
CalcCompleted bool `xml:"calcCompleted,attr,omitempty"`
CalcID string `xml:"calcId,attr,omitempty"`
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册