Documentation ¶
Overview ¶
Package excel is designed to seamlessly integrate with Excel Data Types, offering an easy-to-use interface for manipulating and managing complex data structures directly within Excel spreadsheets. It extends the capabilities of the Excel JavaScript API, supporting an expanded range of data types beyond the basic string, number, boolean, and error types. With this package, developers can work with web images, formatted number values, entities, arrays within entities, and enhanced error data types, thereby unlocking new dimensions of data manipulation and presentation in Excel.
Features:
- Web Images Integration: Allows embedding and manipulation of web images within Excel cells, facilitating richer data visualization and context.
- Formatted Number Values: Supports formatted number values, enabling precise numerical data representation with customized formatting.
- Entity Management: Provides tools to create, modify, and display entities as entity cards, enriching Excel sheets with structured and linked data.
- Array Support within Entities: Enables the use of arrays within entities, allowing for complex data structures to be organized and accessed efficiently.
- Improved Error Handling: Introduces advanced error data types and handling mechanisms, improving the robustness and reliability of Excel add-ins.
Index ¶
- func ArrayValue(elements [][]CellValue) arrayCellValue
- func BoolValue(x bool) booleanCellValue
- func DateValue(x *date.Date, format string) formattedNumber
- func DoubleValue(x float64) doubleCellValue
- func EmptyValue() emptyCellValue
- func EntityValue(text string, properties map[string]CellValue, layouts *Layouts, ...) entityCellValue
- func FormattedNumber(x float64, format string) formattedNumber
- func SaveToLocalFiles(c CellValue) error
- func StringValue(x string) stringCellValue
- type Card
- type CardProperty
- type CellValue
- type Compact
- type Layouts
- type Provider
- type Section
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ArrayValue ¶
func ArrayValue(elements [][]CellValue) arrayCellValue
ArrayValue is a helper function to generate a ArrayCellValue object This ArrayValue may not contain an ArrayValue (i.e. list of a list)
func BoolValue ¶
func BoolValue(x bool) booleanCellValue
BoolValue is a helper function to generate a BooleanCellValue object
func DateValue ¶
DateValue is a helper function to generate a Date cell with a specified format.
Format examples, for the value 31 January 1980
- yy-mm-dd -> 80-01-31
- yyyy-mm-dd -> 1980-01-31
- d mmm yyyy -> 31 Jan 1980
- d mmmm yyyy, dddd -> 31 January 1980, Saturday
func DoubleValue ¶
func DoubleValue(x float64) doubleCellValue
DoubleValue is a helper function to generate a DoubleCellValue object
func EmptyValue ¶ added in v0.0.10
func EmptyValue() emptyCellValue
EmptyValue is a helper function to generate a EmptyCellValue object
func EntityValue ¶ added in v0.0.2
func EntityValue(text string, properties map[string]CellValue, layouts *Layouts, provider *Provider) entityCellValue
Entity is a helper function to generate a new EntityCellValue object, i.e. an Excel Card.
Example ¶
package main import ( "go.alis.build/excel" "google.golang.org/genproto/googleapis/type/date" ) func main() { e := excel.EntityValue( "Card Top Title", map[string]excel.CellValue{ "Total Amount": excel.DoubleValue(7777.77), "Price": excel.FormattedNumber(55.40, "$0.00"), "Validated": excel.BoolValue(true), "Owner": excel.StringValue("Jan Krynauw"), "Items": excel.ArrayValue([][]excel.CellValue{ { excel.StringValue("Thomas"), excel.StringValue("Scholtz"), excel.FormattedNumber(8.03, "$0.0"), }, { excel.StringValue("James"), excel.StringValue("Spanjaard"), excel.FormattedNumber(28.3, "$0.0"), }, }), "Effective Date": excel.DateValue(&date.Date{ Year: 1980, Month: 2, Day: 2, }, "yyyy-mm-dd"), "Sub Properties A": excel.EntityValue( "Another one", map[string]excel.CellValue{ "Key 1": excel.StringValue("Value 1"), "Key 2": excel.StringValue("Value 2"), }, nil, nil), }, &excel.Layouts{ Compact: &excel.Compact{ Icon: "Cloud", }, Card: &excel.Card{ Title: &excel.CardProperty{ Property: "Owner", }, SubTitle: &excel.CardProperty{ Property: "Effective Date", }, }, }, &excel.Provider{ Description: "Some nice description", LogoTargetAddress: "", }, ) // Generate a JSON jsonBytes, _ := e.ToJSON() _ = jsonBytes // Generate ScriptLabImportYAML importXML, _ := e.ToScriptLabYAML() _ = importXML }
Output:
func FormattedNumber ¶ added in v0.0.2
FormattedNumber is a helper function to generate a FormattedCellValue object.
Format examples, for the value 1234.56
- $0.00 -> $1234.56
- $# ##0.00 -> $1 234.56
- $ # -> $ 1234
- "[Blue]#,##0.00_);[Red](#,##0.00);0.00;" -> 1,234.56 (in blue)
func SaveToLocalFiles ¶ added in v0.0.9
SaveToLocalFiles saves a data.json and script.yaml files locally for testing purposes.
func StringValue ¶
func StringValue(x string) stringCellValue
BoolValue is a helper function to generate a BooleanCellValue object
Types ¶
type Card ¶ added in v0.0.2
type Card struct { // Represents the title of the card or the specification of which property contains the title of the card. Title *CardProperty `json:"title,omitempty"` // Represents a specification of which property contains the subtitle of the card. SubTitle *CardProperty `json:"subTitle,omitempty"` // Specifies a property which will be used as the main image of the card. MainImage *CardProperty `json:"mainImage,omitempty"` // Represents the sections of the card. Sections []Section `json:"sections,omitempty"` }
Card represents the layout of a card in card view. https://learn.microsoft.com/en-us/javascript/api/excel/excel.cardlayout TODO: implement EntityArrayCardLayout version of the CardLayout type.
type CardProperty ¶ added in v0.0.2
type CardProperty struct { // The key of the relevant property within the Properties map attribute Property string `json:"property,omitempty"` }
type Compact ¶ added in v0.0.2
type Compact struct { // Specifies the name of the icon which is used to open the card. // Examples: Airplane, Alert, Code, Cloud, ShoppingBag, etc. // Full list of icons available at https://learn.microsoft.com/en-us/javascript/api/excel/excel.entitycompactlayouticons Icon string `json:"icon,omitempty"` }
Compact represents the compact layout properties for an entity, as defined at: https://learn.microsoft.com/en-us/javascript/api/excel/excel.entitycompactlayout
type Layouts ¶ added in v0.0.2
type Layouts struct { // Represents the layout used when there is limited space to represent the entity. Compact *Compact `json:"compact,omitempty"` // Represents the layout of this entity in card view. Card *Card `json:"card,omitempty"` }
entityViewLayouts represents layout information for various views of the entity. Defined at: https://learn.microsoft.com/en-us/javascript/api/excel/excel.entityviewlayouts
type Provider ¶ added in v0.0.2
type Provider struct { // Represents the provider description property that is used in card view if no logo is specified. // If a logo is specified, this will be used as tooltip text. Description string `json:"description,omitempty"` // Represents a URL used to download an image that will be used as a logo in card view. LogoSourceAddress string `json:"logoSourceAddress,omitempty"` // Represents a URL that is the navigation target if the user clicks on the logo element in card view LogoTargetAddress string `json:"logoTargetAddress,omitempty"` }
CellValueProviderAttributes as defined at: https://learn.microsoft.com/en-us/javascript/api/excel/excel.cellvalueproviderattributes
type Section ¶ added in v0.0.2
type Section struct { // Represents the type of layout for this section. // Available values: "List", "Table" Layout string `json:"layout,omitempty"` // Represents the names of the properties in this section. Properties []string `json:"properties,omitempty"` // Represents the title of this section of the card. Title *string `json:"title,omitempty"` // Represents whether this section of the card is collapsible. If the card section // has a title, the default value is true. If the card section doesn't have a title, // the default value is false. Collapsible *bool `json:"collapsible,omitempty"` // Represents whether this section of the card is initially collapsed. Collapsed *bool `json:"collapsed,omitempty"` }
Represents the layout of a section of a card in card view. https://learn.microsoft.com/en-us/javascript/api/excel/excel.cardlayoutsection