From 52796f6e58e95145e2964d0d313a2f721dcc040e Mon Sep 17 00:00:00 2001 From: Ri Xu Date: Wed, 18 Jan 2017 16:05:01 +0800 Subject: [PATCH] Format commants, break comments after 80 characters. --- cell.go | 7 +- col.go | 4 +- excelize.go | 20 ++-- excelize_test.go | 46 ++++----- file.go | 13 ++- lib.go | 18 ++-- picture.go | 46 +++++---- rows.go | 5 +- sheet.go | 50 +++++----- xmlDecodeDrawing.go | 14 +-- xmlDrawing.go | 110 +++++++++++----------- xmlSharedStrings.go | 14 ++- xmlWorkbook.go | 120 +++++++++++------------- xmlWorksheet.go | 221 ++++++++++++++++++++------------------------ 14 files changed, 342 insertions(+), 346 deletions(-) diff --git a/cell.go b/cell.go index d881220..f91b661 100644 --- a/cell.go +++ b/cell.go @@ -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 diff --git a/col.go b/col.go index dbe004d..7b583c5 100644 --- a/col.go +++ b/col.go @@ -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) diff --git a/excelize.go b/excelize.go index f22af37..fed9613 100644 --- a/excelize.go +++ b/excelize.go @@ -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 := `` newXmlns := `` @@ -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: // // // @@ -232,7 +234,8 @@ func replaceWorkSheetsRelationshipsNameSpace(workbookMarshal string) string { // // // -// 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. diff --git a/excelize_test.go b/excelize_test.go index 3c926ca..6e41968 100644 --- a/excelize_test.go +++ b/excelize_test.go @@ -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) } diff --git a/file.go b/file.go index 654fe59..e43d05f 100644 --- a/file.go +++ b/file.go @@ -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) diff --git a/lib.go b/lib.go index dfd1bdc..7b9174e 100644 --- a/lib.go +++ b/lib.go @@ -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 diff --git a/picture.go b/picture.go index 62054fc..62559de 100644 --- a/picture.go +++ b/picture.go @@ -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 diff --git a/rows.go b/rows.go index 3d74b27..384ee7d 100644 --- a/rows.go +++ b/rows.go @@ -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": diff --git a/sheet.go b/sheet.go index eeccde9..3f117af 100644 --- a/sheet.go +++ b/sheet.go @@ -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 := `` newXmlns := `` 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) diff --git a/xmlDecodeDrawing.go b/xmlDecodeDrawing.go index 7965a14..136975e 100644 --- a/xmlDecodeDrawing.go +++ b/xmlDecodeDrawing.go @@ -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"` diff --git a/xmlDrawing.go b/xmlDrawing.go index b0f1f46..89854ec 100644 --- a/xmlDrawing.go +++ b/xmlDrawing.go @@ -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"` diff --git a/xmlSharedStrings.go b/xmlSharedStrings.go index 03d1ed4..402d3f3 100644 --- a/xmlSharedStrings.go +++ b/xmlSharedStrings.go @@ -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"` } diff --git a/xmlWorkbook.go b/xmlWorkbook.go index 6ba7b53..775d01b 100644 --- a/xmlWorkbook.go +++ b/xmlWorkbook.go @@ -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"` diff --git a/xmlWorksheet.go b/xmlWorksheet.go index bc17403..2dbb1b1 100644 --- a/xmlWorksheet.go +++ b/xmlWorksheet.go @@ -3,9 +3,8 @@ package excelize import "encoding/xml" // xlsxWorksheet directly maps the worksheet 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. +// http://schemas.openxmlformats.org/spreadsheetml/2006/main - currently I have +// not checked it for completeness - it does as much as I need. type xlsxWorksheet struct { XMLName xml.Name `xml:"http://schemas.openxmlformats.org/spreadsheetml/2006/main worksheet"` SheetPr *xlsxSheetPr `xml:"sheetPr"` @@ -35,13 +34,12 @@ type xlsxDrawing struct { } // xlsxHeaderFooter directly maps the headerFooter element in the namespace -// http://schemas.openxmlformats.org/spreadsheetml/2006/main - -// When printed or viewed in page layout view (§18.18.69), each page of a -// worksheet can have a page header, a page footer, or both. The headers and -// footers on odd-numbered pages can differ from those on even-numbered pages, -// and the headers and footers on the first page can differ from those on odd- -// and even-numbered pages. In the latter case, the first page is not considered -// an odd page. +// http://schemas.openxmlformats.org/spreadsheetml/2006/main - When printed or +// viewed in page layout view (§18.18.69), each page of a worksheet can have a +// page header, a page footer, or both. The headers and footers on odd-numbered +// pages can differ from those on even-numbered pages, and the headers and +// footers on the first page can differ from those on odd- and even-numbered +// pages. In the latter case, the first page is not considered an odd page. type xlsxHeaderFooter struct { DifferentFirst bool `xml:"differentFirst,attr,omitempty"` DifferentOddEven bool `xml:"differentOddEven,attr,omitempty"` @@ -50,24 +48,22 @@ type xlsxHeaderFooter struct { } // xlsxOddHeader directly maps the oddHeader 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. +// http://schemas.openxmlformats.org/spreadsheetml/2006/main - currently I have +// not checked it for completeness - it does as much as I need. type xlsxOddHeader struct { Content string `xml:",chardata"` } // xlsxOddFooter directly maps the oddFooter 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. +// http://schemas.openxmlformats.org/spreadsheetml/2006/main - currently I have +// not checked it for completeness - it does as much as I need. type xlsxOddFooter struct { Content string `xml:",chardata"` } // xlsxPageSetUp directly maps the pageSetup element in the namespace -// http://schemas.openxmlformats.org/spreadsheetml/2006/main - -// Page setup settings for the worksheet. +// http://schemas.openxmlformats.org/spreadsheetml/2006/main - Page setup +// settings for the worksheet. type xlsxPageSetUp struct { BlackAndWhite bool `xml:"blackAndWhite,attr,omitempty"` CellComments string `xml:"cellComments,attr,omitempty"` @@ -91,9 +87,9 @@ type xlsxPageSetUp struct { } // xlsxPrintOptions directly maps the printOptions element in the namespace -// http://schemas.openxmlformats.org/spreadsheetml/2006/main - -// Print options for the sheet. Printer-specific settings are stored separately -// in the Printer Settings part. +// http://schemas.openxmlformats.org/spreadsheetml/2006/main - Print options for +// the sheet. Printer-specific settings are stored separately in the Printer +// Settings part. type xlsxPrintOptions struct { GridLines bool `xml:"gridLines,attr,omitempty"` GridLinesSet bool `xml:"gridLinesSet,attr,omitempty"` @@ -103,8 +99,8 @@ type xlsxPrintOptions struct { } // xlsxPageMargins directly maps the pageMargins element in the namespace -// http://schemas.openxmlformats.org/spreadsheetml/2006/main - -// Page margins for a sheet or a custom sheet view. +// http://schemas.openxmlformats.org/spreadsheetml/2006/main - Page margins for +// a sheet or a custom sheet view. type xlsxPageMargins struct { Bottom float64 `xml:"bottom,attr"` Footer float64 `xml:"footer,attr"` @@ -115,9 +111,8 @@ type xlsxPageMargins struct { } // xlsxSheetFormatPr directly maps the sheetFormatPr 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. +// http://schemas.openxmlformats.org/spreadsheetml/2006/main - currently I have +// not checked it for completeness - it does as much as I need. type xlsxSheetFormatPr struct { DefaultColWidth float64 `xml:"defaultColWidth,attr,omitempty"` DefaultRowHeight float64 `xml:"defaultRowHeight,attr"` @@ -128,24 +123,21 @@ type xlsxSheetFormatPr struct { } // xlsxSheetViews directly maps the sheetViews element in the namespace -// http://schemas.openxmlformats.org/spreadsheetml/2006/main - -// Worksheet views collection. +// http://schemas.openxmlformats.org/spreadsheetml/2006/main - Worksheet views +// collection. type xlsxSheetViews struct { 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 +// 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. type xlsxSheetView struct { WindowProtection bool `xml:"windowProtection,attr,omitempty"` @@ -169,8 +161,8 @@ type xlsxSheetView struct { } // xlsxSelection directly maps the selection element in the namespace -// http://schemas.openxmlformats.org/spreadsheetml/2006/main - -// Worksheet view selection. +// http://schemas.openxmlformats.org/spreadsheetml/2006/main - Worksheet view +// selection. type xlsxSelection struct { ActiveCell string `xml:"activeCell,attr,omitempty"` ActiveCellID int `xml:"activeCellId,attr"` @@ -178,8 +170,7 @@ type xlsxSelection struct { SQRef string `xml:"sqref,attr,omitempty"` } -// xlsxSelection directly maps the selection element. -// Worksheet view pane. +// xlsxSelection directly maps the selection element. Worksheet view pane. type xlsxPane struct { ActivePane string `xml:"activePane,attr,omitempty"` State string `xml:"state,attr,omitempty"` // Either "split" or "frozen" @@ -189,8 +180,8 @@ type xlsxPane struct { } // xlsxSheetPr directly maps the sheetPr element in the namespace -// http://schemas.openxmlformats.org/spreadsheetml/2006/main - -// Sheet-level properties. +// http://schemas.openxmlformats.org/spreadsheetml/2006/main - Sheet-level +// properties. type xlsxSheetPr struct { XMLName xml.Name `xml:"sheetPr"` CodeName string `xml:"codeName,attr,omitempty"` @@ -205,25 +196,23 @@ type xlsxSheetPr struct { } // xlsxPageSetUpPr directly maps the pageSetupPr element in the namespace -// http://schemas.openxmlformats.org/spreadsheetml/2006/main - -// Page setup properties of the worksheet. +// http://schemas.openxmlformats.org/spreadsheetml/2006/main - 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. } -// 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 directly maps the tabColor element in the namespace currently I +// have not checked it for completeness - it does as much as I need. type xlsxTabColor struct { - Theme int `xml:"theme,attr,omitempty"` // (Theme Color) A zero-based index into the collection (§20.1.6.2), referencing a particular or value expressed in the Theme part. - Tint uint8 `xml:"tint,attr,omitempty"` // Specifies the tint value applied to the color. + Theme int `xml:"theme,attr,omitempty"` + Tint uint8 `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. +// http://schemas.openxmlformats.org/spreadsheetml/2006/main - currently I have +// not checked it for completeness - it does as much as I need. type xlsxCols struct { Col []xlsxCol `xml:"col"` } @@ -244,28 +233,27 @@ 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. +// 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. type xlsxDimension struct { 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. +// http://schemas.openxmlformats.org/spreadsheetml/2006/main - currently I have +// not checked it for completeness - it does as much as I need. type xlsxSheetData struct { XMLName xml.Name `xml:"sheetData"` Row []xlsxRow `xml:"row"` } // xlsxRow directly maps the row element. The element expresses information -// about an entire row of a worksheet, and contains all cell definitions for -// a particular row in the worksheet. +// about an entire row of a worksheet, and contains all cell definitions for a +// particular row in the worksheet. type xlsxRow struct { Collapsed bool `xml:"collapsed,attr,omitempty"` CustomFormat bool `xml:"customFormat,attr,omitempty"` @@ -284,20 +272,19 @@ type xlsxRow struct { // xlsxMergeCell directly maps the mergeCell element. A single merged cell. type xlsxMergeCell struct { - Ref string `xml:"ref,attr,omitempty"` // ref: horiz "A1:C1", vert "B3:B6", both "D3:G4" + Ref string `xml:"ref,attr,omitempty"` } -// xlsxMergeCells directly maps the mergeCells element. This collection expresses -// all the merged cells in the sheet. +// xlsxMergeCells directly maps the mergeCells element. This collection +// expresses all the merged cells in the sheet. type xlsxMergeCells struct { Count int `xml:"count,attr,omitempty"` Cells []*xlsxMergeCell `xml:"mergeCell,omitempty"` } // 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. +// http://schemas.openxmlformats.org/spreadsheetml/2006/main - currently I have +// not checked it for completeness - it does as much as I need. type xlsxC struct { R string `xml:"r,attr"` // Cell ID, e.g. A1 S int `xml:"s,attr,omitempty"` // Style reference. @@ -308,9 +295,8 @@ type xlsxC struct { } // 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. +// http://schemas.openxmlformats.org/spreadsheetml/2006/main - currently I have +// not checked it for completeness - it does as much as I need. type xlsxF struct { Content string `xml:",chardata"` T string `xml:"t,attr,omitempty"` // Formula type @@ -318,8 +304,8 @@ type xlsxF struct { Si string `xml:"si,attr,omitempty"` // Shared formula index } -// xlsxSheetProtection collection expresses the sheet protection options -// to enforce when the sheet is protected. +// xlsxSheetProtection collection expresses the sheet protection options to +// enforce when the sheet is protected. type xlsxSheetProtection struct { AlgorithmName string `xml:"algorithmName,attr,omitempty"` AutoFilter int `xml:"autoFilter,attr,omitempty"` @@ -343,19 +329,18 @@ type xlsxSheetProtection struct { SpinCount int `xml:"spinCount,attr,omitempty"` } -// A Conditional Format is a format, such as cell shading or font color, -// that a spreadsheet application can automatically apply to cells if a -// specified condition is true. This collection expresses conditional -// formatting rules applied to a particular cell or range. +// A Conditional Format is a format, such as cell shading or font color, that a +// spreadsheet application can automatically apply to cells if a specified +// condition is true. This collection expresses conditional formatting rules +// applied to a particular cell or range. type xlsxConditionalFormatting struct { CfRule string `xml:",innerxml"` } // xlsxHyperlinks directly maps the hyperlinks element in the namespace -// http://schemas.openxmlformats.org/spreadsheetml/2006/main - -// A hyperlink can be stored in a package as a relationship. Hyperlinks -// shall be identified by containing a target which specifies the -// destination of the given hyperlink. +// http://schemas.openxmlformats.org/spreadsheetml/2006/main - A hyperlink can +// be stored in a package as a relationship. Hyperlinks shall be identified by +// containing a target which specifies the destination of the given hyperlink. type xlsxHyperlinks struct { Hyperlink []xlsxHyperlink `xml:"hyperlink"` } @@ -370,31 +355,28 @@ type xlsxHyperlink struct { } // xlsxTableParts directly maps the tableParts element in the namespace -// http://schemas.openxmlformats.org/spreadsheetml/2006/main - -// The table element has several attributes applied to identify the table -// and the data range it covers. The table id attribute needs to be unique -// across all table parts, the same goes for the name and displayName. The -// displayName has the further restriction that it must be unique across -// all defined names in the workbook. Later on we will see that you can -// define names for many elements, such as cells or formulas. The name -// value is used for the object model in Microsoft Office Excel. The -// displayName is used for references in formulas. The ref attribute is -// used to identify the cell range that the table covers. This includes -// not only the table data, but also the table header containing column +// http://schemas.openxmlformats.org/spreadsheetml/2006/main - The table element +// has several attributes applied to identify the table and the data range it +// covers. The table id attribute needs to be unique across all table parts, the +// same goes for the name and displayName. The displayName has the further +// restriction that it must be unique across all defined names in the workbook. +// Later on we will see that you can define names for many elements, such as +// cells or formulas. The name value is used for the object model in Microsoft +// Office Excel. The displayName is used for references in formulas. The ref +// attribute is used to identify the cell range that the table covers. This +// includes not only the table data, but also the table header containing column // names. // To add columns to your table you add new tableColumn elements to the -// tableColumns container. Similar to the shared string table the -// collection keeps a count attribute identifying the number of columns. -// Besides the table definition in the table part there is also the need -// to identify which tables are displayed in the worksheet. The worksheet -// part has a separate element tableParts to store this information. Each -// table part is referenced through the relationship ID and again a count -// of the number of table parts is maintained. The following markup sample -// is taken from the documents accompanying this book. The sheet data -// element has been removed to reduce the size of the sample. To reference -// the table, just add the tableParts element, of course after having -// created and stored the table part. -// Example: +// tableColumns container. Similar to the shared string table the collection +// keeps a count attribute identifying the number of columns. Besides the table +// definition in the table part there is also the need to identify which tables +// are displayed in the worksheet. The worksheet part has a separate element +// tableParts to store this information. Each table part is referenced through +// the relationship ID and again a count of the number of table parts is +// maintained. The following markup sample is taken from the documents +// accompanying this book. The sheet data element has been removed to reduce the +// size of the sample. To reference the table, just add the tableParts element, +// of course after having created and stored the table part. For example: // // // ... @@ -415,25 +397,24 @@ type xlsxTablePart struct { } // xlsxPicture directly maps the picture element in the namespace -// http://schemas.openxmlformats.org/spreadsheetml/2006/main - -// Background sheet image. -// Example: +// http://schemas.openxmlformats.org/spreadsheetml/2006/main - Background sheet +// image. For example: // // // type xlsxPicture struct { - RID string `xml:"http://schemas.openxmlformats.org/officeDocument/2006/relationships id,attr,omitempty"` // Relationship Id pointing to the image part. + RID string `xml:"http://schemas.openxmlformats.org/officeDocument/2006/relationships id,attr,omitempty"` } // xlsxLegacyDrawing directly maps the legacyDrawing element in the namespace -// http://schemas.openxmlformats.org/spreadsheetml/2006/main - -// A comment is a rich text note that is attached to, and associated with, -// a cell, separate from other cell content. Comment content is stored -// separate from the cell, and is displayed in a drawing object (like a -// text box) that is separate from, but associated with, a cell. Comments -// are used as reminders, such as noting how a complex formula works, or -// to provide feedback to other users. Comments can also be used to explain -// assumptions made in a formula or to call out something special about the cell. +// http://schemas.openxmlformats.org/spreadsheetml/2006/main - A comment is a +// rich text note that is attached to, and associated with, a cell, separate +// from other cell content. Comment content is stored separate from the cell, +// and is displayed in a drawing object (like a text box) that is separate from, +// but associated with, a cell. Comments are used as reminders, such as noting +// how a complex formula works, or to provide feedback to other users. Comments +// can also be used to explain assumptions made in a formula or to call out +// something special about the cell. type xlsxLegacyDrawing struct { RID string `xml:"http://schemas.openxmlformats.org/officeDocument/2006/relationships id,attr,omitempty"` } -- GitLab