|
|
@ -16,6 +16,7 @@ import (
|
|
|
|
"reflect"
|
|
|
|
"reflect"
|
|
|
|
"strconv"
|
|
|
|
"strconv"
|
|
|
|
"strings"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"sync"
|
|
|
|
"time"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
@ -30,6 +31,8 @@ const (
|
|
|
|
STCellFormulaTypeShared = "shared"
|
|
|
|
STCellFormulaTypeShared = "shared"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var rwMutex sync.RWMutex
|
|
|
|
|
|
|
|
|
|
|
|
// GetCellValue provides a function to get formatted value from cell by given
|
|
|
|
// GetCellValue provides a function to get formatted value from cell by given
|
|
|
|
// worksheet name and axis in XLSX file. If it is possible to apply a format
|
|
|
|
// worksheet name and axis in XLSX file. If it is possible to apply a format
|
|
|
|
// to the cell value, it will do so, if not then an error will be returned,
|
|
|
|
// to the cell value, it will do so, if not then an error will be returned,
|
|
|
@ -155,6 +158,8 @@ func (f *File) setCellTimeFunc(sheet, axis string, value time.Time) error {
|
|
|
|
// SetCellInt provides a function to set int type value of a cell by given
|
|
|
|
// SetCellInt provides a function to set int type value of a cell by given
|
|
|
|
// worksheet name, cell coordinates and cell value.
|
|
|
|
// worksheet name, cell coordinates and cell value.
|
|
|
|
func (f *File) SetCellInt(sheet, axis string, value int) error {
|
|
|
|
func (f *File) SetCellInt(sheet, axis string, value int) error {
|
|
|
|
|
|
|
|
rwMutex.Lock()
|
|
|
|
|
|
|
|
defer rwMutex.Unlock()
|
|
|
|
xlsx, err := f.workSheetReader(sheet)
|
|
|
|
xlsx, err := f.workSheetReader(sheet)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
@ -172,6 +177,8 @@ func (f *File) SetCellInt(sheet, axis string, value int) error {
|
|
|
|
// SetCellBool provides a function to set bool type value of a cell by given
|
|
|
|
// SetCellBool provides a function to set bool type value of a cell by given
|
|
|
|
// worksheet name, cell name and cell value.
|
|
|
|
// worksheet name, cell name and cell value.
|
|
|
|
func (f *File) SetCellBool(sheet, axis string, value bool) error {
|
|
|
|
func (f *File) SetCellBool(sheet, axis string, value bool) error {
|
|
|
|
|
|
|
|
rwMutex.Lock()
|
|
|
|
|
|
|
|
defer rwMutex.Unlock()
|
|
|
|
xlsx, err := f.workSheetReader(sheet)
|
|
|
|
xlsx, err := f.workSheetReader(sheet)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
@ -200,6 +207,8 @@ func (f *File) SetCellBool(sheet, axis string, value bool) error {
|
|
|
|
// f.SetCellFloat("Sheet1", "A1", float64(x), 2, 32)
|
|
|
|
// f.SetCellFloat("Sheet1", "A1", float64(x), 2, 32)
|
|
|
|
//
|
|
|
|
//
|
|
|
|
func (f *File) SetCellFloat(sheet, axis string, value float64, prec, bitSize int) error {
|
|
|
|
func (f *File) SetCellFloat(sheet, axis string, value float64, prec, bitSize int) error {
|
|
|
|
|
|
|
|
rwMutex.Lock()
|
|
|
|
|
|
|
|
defer rwMutex.Unlock()
|
|
|
|
xlsx, err := f.workSheetReader(sheet)
|
|
|
|
xlsx, err := f.workSheetReader(sheet)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
@ -217,6 +226,8 @@ func (f *File) SetCellFloat(sheet, axis string, value float64, prec, bitSize int
|
|
|
|
// SetCellStr provides a function to set string type value of a cell. Total
|
|
|
|
// SetCellStr provides a function to set string type value of a cell. Total
|
|
|
|
// number of characters that a cell can contain 32767 characters.
|
|
|
|
// number of characters that a cell can contain 32767 characters.
|
|
|
|
func (f *File) SetCellStr(sheet, axis, value string) error {
|
|
|
|
func (f *File) SetCellStr(sheet, axis, value string) error {
|
|
|
|
|
|
|
|
rwMutex.Lock()
|
|
|
|
|
|
|
|
defer rwMutex.Unlock()
|
|
|
|
xlsx, err := f.workSheetReader(sheet)
|
|
|
|
xlsx, err := f.workSheetReader(sheet)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
@ -276,6 +287,8 @@ func (f *File) GetCellFormula(sheet, axis string) (string, error) {
|
|
|
|
// SetCellFormula provides a function to set cell formula by given string and
|
|
|
|
// SetCellFormula provides a function to set cell formula by given string and
|
|
|
|
// worksheet name.
|
|
|
|
// worksheet name.
|
|
|
|
func (f *File) SetCellFormula(sheet, axis, formula string) error {
|
|
|
|
func (f *File) SetCellFormula(sheet, axis, formula string) error {
|
|
|
|
|
|
|
|
rwMutex.Lock()
|
|
|
|
|
|
|
|
defer rwMutex.Unlock()
|
|
|
|
xlsx, err := f.workSheetReader(sheet)
|
|
|
|
xlsx, err := f.workSheetReader(sheet)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|