Vyacheslav Zgordan dd7713e1e3 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-20 23:21:00 +00:00

67 lines
1.8 KiB
Go

// Copyright 2017 FoxyUtils ehf. All rights reserved.
//
// 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
// commercial license can be purchased on https://unidoc.io.
package document
import "github.com/unidoc/unioffice/schema/soo/wml"
// Cell is a table cell within a document (not a spreadsheet)
type Cell struct {
d *Document
x *wml.CT_Tc
}
// X returns the inner wrapped XML type.
func (c Cell) X() *wml.CT_Tc {
return c.x
}
// AddParagraph adds a paragraph to the table cell.
func (c Cell) AddParagraph() Paragraph {
ble := wml.NewEG_BlockLevelElts()
c.x.EG_BlockLevelElts = append(c.x.EG_BlockLevelElts, ble)
bc := wml.NewEG_ContentBlockContent()
ble.EG_ContentBlockContent = append(ble.EG_ContentBlockContent, bc)
p := wml.NewCT_P()
bc.P = append(bc.P, p)
return Paragraph{c.d, p}
}
// AddTable adds a table to the table cell.
func (c Cell) AddTable() Table {
ble := wml.NewEG_BlockLevelElts()
c.x.EG_BlockLevelElts = append(c.x.EG_BlockLevelElts, ble)
bc := wml.NewEG_ContentBlockContent()
ble.EG_ContentBlockContent = append(ble.EG_ContentBlockContent, bc)
tbl := wml.NewCT_Tbl()
bc.Tbl = append(bc.Tbl, tbl)
return Table{c.d, tbl}
}
// Properties returns the cell properties.
func (c Cell) Properties() CellProperties {
if c.x.TcPr == nil {
c.x.TcPr = wml.NewCT_TcPr()
}
return CellProperties{c.x.TcPr}
}
// Paragraphs returns the paragraphs defined in the cell.
func (c Cell) Paragraphs() []Paragraph {
ret := []Paragraph{}
for _, ble := range c.x.EG_BlockLevelElts {
for _, cbc := range ble.EG_ContentBlockContent {
for _, p := range cbc.P {
ret = append(ret, Paragraph{c.d, p})
}
}
}
return ret
}