2019-07-25 19:43:46 +03:00
|
|
|
// Copyright 2017 FoxyUtils ehf. All rights reserved.
|
2017-09-06 16:30:52 -04:00
|
|
|
//
|
|
|
|
// Use of this source code is governed by the terms of the Affero GNU General
|
|
|
|
// Public License version 3.0 as published by the Free Software Foundation and
|
|
|
|
// appearing in the file LICENSE included in the packaging of this file. A
|
Functions2 (#348)
* MATCH, IFS, MAXA, MINA
* OFFSET fixed
* ISBLANK, ISERR, ISERROR, ISEVEN ,ISFORMULA, ISNONTEXT, ISNUMBER, ISODD, ISTEXT
* ISLEAPYEAR, ISLOGICAL, ISNA, ISREF
* FIND, FINDB
* SEARCH, SEARCHB
* CONCAT, CONCATENATE
* YEAR, YEARFRAC
* CONCAT is fixed, now TRUE and FALSE are concatenated instead of 1 and 0 in case of boolean results
* NOW, TODAY, TIME, TIMEVALUE
* DATE
* DATEDIF
2019-11-21 02:21:00 +03:00
|
|
|
// commercial license can be purchased on https://unidoc.io.
|
2017-09-06 16:30:52 -04:00
|
|
|
|
|
|
|
package spreadsheet_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"time"
|
|
|
|
|
2019-05-04 11:18:06 +03:00
|
|
|
"github.com/unidoc/unioffice/spreadsheet"
|
2017-09-06 16:30:52 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
func ExampleSheet_Cell() {
|
|
|
|
wb := spreadsheet.New()
|
|
|
|
sheet := wb.AddSheet()
|
|
|
|
|
|
|
|
// Cell creates or returns a cell with a given reference
|
|
|
|
sheet.Cell("A1").SetNumber(1.23)
|
|
|
|
}
|
|
|
|
|
|
|
|
func ExampleSheet_Row() {
|
|
|
|
wb := spreadsheet.New()
|
|
|
|
sheet := wb.AddSheet()
|
|
|
|
|
|
|
|
// Row/Cell create or returns a cell with a given reference
|
|
|
|
sheet.Row(1).Cell("A").SetNumber(1.23)
|
|
|
|
}
|
|
|
|
|
|
|
|
func ExampleSheet_AddRow() {
|
|
|
|
wb := spreadsheet.New()
|
|
|
|
sheet := wb.AddSheet()
|
|
|
|
|
|
|
|
// AddRow/AddCell add a new unspecified row/cell. These will be numbered
|
|
|
|
// sequentially in the resulting file.
|
|
|
|
sheet.AddRow().AddCell().SetNumber(1.23)
|
|
|
|
}
|
|
|
|
|
|
|
|
func ExampleSheet_AddNumberedRow() {
|
|
|
|
wb := spreadsheet.New()
|
|
|
|
sheet := wb.AddSheet()
|
|
|
|
|
|
|
|
// AddNumberedRow adds a row with a given number, the difference between Row
|
|
|
|
// and AddNumberedRow is that AddNumberedRow doesn't check for an existing
|
|
|
|
// row with the same number, while Row will return an existing row if it exists.
|
|
|
|
sheet.AddNumberedRow(5).AddCell().SetNumber(1.23)
|
|
|
|
}
|
|
|
|
|
|
|
|
func ExampleSheet_Name() {
|
|
|
|
wb := spreadsheet.New()
|
|
|
|
sheet := wb.AddSheet()
|
|
|
|
sheet.SetName("Sheet 1")
|
|
|
|
fmt.Println(sheet.Name())
|
|
|
|
|
|
|
|
// Output: Sheet 1
|
|
|
|
}
|
|
|
|
|
|
|
|
func ExampleCell_SetDate() {
|
|
|
|
wb := spreadsheet.New()
|
|
|
|
sheet := wb.AddSheet()
|
|
|
|
cell := sheet.Cell("A1")
|
|
|
|
// set our date value
|
|
|
|
cell.SetDate(time.Now())
|
|
|
|
|
|
|
|
// then display it with a date style
|
|
|
|
dateStyle := wb.StyleSheet.AddCellStyle()
|
|
|
|
dateStyle.SetNumberFormatStandard(spreadsheet.StandardFormatDate)
|
|
|
|
cell.SetStyle(dateStyle)
|
|
|
|
}
|
|
|
|
|
|
|
|
func ExampleCell_SetDateWithStyle() {
|
|
|
|
wb := spreadsheet.New()
|
|
|
|
sheet := wb.AddSheet()
|
|
|
|
cell := sheet.Cell("A1")
|
|
|
|
|
|
|
|
cell.SetDateWithStyle(time.Now())
|
|
|
|
}
|