diff options
Diffstat (limited to 'lib.go')
-rw-r--r-- | lib.go | 51 |
1 files changed, 29 insertions, 22 deletions
@@ -1,9 +1,17 @@ +// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of +// this source code is governed by a BSD-style license that can be found in +// the LICENSE file. +// +// Package excelize providing a set of functions that allow you to write to +// and read from XLSX files. Support reads and writes XLSX file generated by +// Microsoft Excelâ„¢ 2007 and later. Support save file without losing original +// charts of XLSX. This library needs Go version 1.8 or later. + package excelize import ( "archive/zip" "bytes" - "encoding/gob" "io" "log" "math" @@ -26,7 +34,7 @@ func ReadZipReader(r *zip.Reader) (map[string][]byte, int, error) { return fileList, worksheets, nil } -// readXML provides function to read XML content as string. +// readXML provides a function to read XML content as string. func (f *File) readXML(name string) []byte { if content, ok := f.XLSX[name]; ok { return content @@ -34,8 +42,8 @@ func (f *File) readXML(name string) []byte { return []byte{} } -// saveFileList provides function to update given file content in file list of -// XLSX. +// saveFileList provides a function to update given file content in file list +// of XLSX. func (f *File) saveFileList(name string, content []byte) { newContent := make([]byte, 0, len(XMLHeader)+len(content)) newContent = append(newContent, []byte(XMLHeader)...) @@ -55,7 +63,7 @@ func readFile(file *zip.File) []byte { return buff.Bytes() } -// ToAlphaString provides function to convert integer to Excel sheet column +// ToAlphaString provides a function to convert integer to Excel sheet column // title. For example convert 36 to column title AK: // // excelize.ToAlphaString(36) @@ -73,9 +81,9 @@ func ToAlphaString(value int) string { return ans } -// TitleToNumber provides function to convert Excel sheet column title to int -// (this function doesn't do value check currently). For example convert AK -// and ak to column title 36: +// TitleToNumber provides a function to convert Excel sheet column title to +// int (this function doesn't do value check currently). For example convert +// AK and ak to column title 36: // // excelize.TitleToNumber("AK") // excelize.TitleToNumber("ak") @@ -115,17 +123,6 @@ func intOnlyMapF(rune rune) rune { return -1 } -// deepCopy provides method to creates a deep copy of whatever is passed to it -// and returns the copy in an interface. The returned value will need to be -// asserted to the correct type. -func deepCopy(dst, src interface{}) error { - var buf bytes.Buffer - if err := gob.NewEncoder(&buf).Encode(src); err != nil { - return err - } - return gob.NewDecoder(bytes.NewBuffer(buf.Bytes())).Decode(dst) -} - // boolPtr returns a pointer to a bool with the given value. func boolPtr(b bool) *bool { return &b } @@ -137,8 +134,8 @@ func defaultTrue(b *bool) bool { return *b } -// axisLowerOrEqualThan returns true if axis1 <= axis2 -// axis1/axis2 can be either a column or a row axis, e.g. "A", "AAE", "42", "1", etc. +// axisLowerOrEqualThan returns true if axis1 <= axis2 axis1/axis2 can be +// either a column or a row axis, e.g. "A", "AAE", "42", "1", etc. // // For instance, the following comparisons are all true: // @@ -159,7 +156,8 @@ func axisLowerOrEqualThan(axis1, axis2 string) bool { } } -// getCellColRow returns the two parts of a cell identifier (its col and row) as strings +// getCellColRow returns the two parts of a cell identifier (its col and row) +// as strings // // For instance: // @@ -176,3 +174,12 @@ func getCellColRow(cell string) (col, row string) { return cell, "" } + +// parseFormatSet provides a method to convert format string to []byte and +// handle empty string. +func parseFormatSet(formatSet string) []byte { + if formatSet != "" { + return []byte(formatSet) + } + return []byte("{}") +} |