MCPcopy Create free account
hub / github.com/plandem/xlsx / Example_append

Function Example_append

example_test.go:362–397  ·  view source on GitHub ↗

Demonstrates how to append cols/rows/sheets.

()

Source from the content-addressed store, hash-verified

360
361// Demonstrates how to append cols/rows/sheets.
362func Example_append() {
363 xl, err := xlsx.Open("./test_files/example_simple.xlsx")
364 if err != nil {
365 log.Fatal(err)
366 }
367
368 defer xl.Close()
369
370 sheet := xl.Sheet(0)
371
372 // To append a new col/row, simple request it - sheet will be auto expanded.
373 // E.g.: we have 14 cols, 28 rows.
374 fmt.Println(sheet.Dimension())
375
376 // Append 72 rows
377 sheet.Row(99)
378 fmt.Println(sheet.Dimension())
379
380 // Append 36 cols
381 sheet.Col(49)
382 fmt.Println(sheet.Dimension())
383
384 // Append 3 sheet
385 fmt.Println(strings.Join(xl.SheetNames(), ","))
386 xl.AddSheet("new sheet")
387 xl.AddSheet("new sheet")
388 xl.AddSheet("new sheet")
389 fmt.Println(strings.Join(xl.SheetNames(), ","))
390
391 //Output:
392 // 14 28
393 // 14 100
394 // 50 100
395 // Sheet1
396 // Sheet1,new sheet,new sheet1,new sheet2
397}
398
399// Demonstrates how to insert cols/rows
400func Example_insert() {

Callers

nothing calls this directly

Calls 8

OpenFunction · 0.92
SheetMethod · 0.80
SheetNamesMethod · 0.80
AddSheetMethod · 0.80
CloseMethod · 0.65
DimensionMethod · 0.65
RowMethod · 0.65
ColMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…