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

Function Example_insert

example_test.go:400–436  ·  view source on GitHub ↗

Demonstrates how to insert cols/rows

()

Source from the content-addressed store, hash-verified

398
399// Demonstrates how to insert cols/rows
400func Example_insert() {
401 xl, err := xlsx.Open("./test_files/example_simple.xlsx")
402 if err != nil {
403 log.Fatal(err)
404 }
405
406 defer xl.Close()
407
408 sheet := xl.Sheet(0)
409
410 fmt.Println(sheet.Dimension())
411 fmt.Println(strings.Join(sheet.Col(3).Values(), ","))
412
413 // Insert a new col
414 sheet.InsertCol(3)
415 fmt.Println(sheet.Dimension())
416 fmt.Println(strings.Join(sheet.Col(3).Values(), ","))
417 fmt.Println(strings.Join(sheet.Col(4).Values(), ","))
418
419 // Insert a new row
420 fmt.Println(strings.Join(sheet.Row(9).Values(), ","))
421 sheet.InsertRow(3)
422 fmt.Println(sheet.Dimension())
423 fmt.Println(strings.Join(sheet.Row(9).Values(), ","))
424 fmt.Println(strings.Join(sheet.Row(10).Values(), ","))
425
426 //Output:
427 // 14 28
428 // ,,,,,,,,,1,6,11,16,,,,,,,,,,,,,,,
429 // 15 28
430 // ,,,,,,,,,,,,,,,,,,,,,,,,,,,
431 // ,,,,,,,,,1,6,11,16,,,,,,,,,,,,,,,
432 // ,,,,1,2,3,4,5,,,,,,
433 // 15 29
434 // ,,,,,,,,,,,,,,
435 // ,,,,1,2,3,4,5,,,,,,
436}
437
438// Demonstrates how to delete information
439func Example_delete() {

Callers

nothing calls this directly

Calls 9

OpenFunction · 0.92
SheetMethod · 0.80
ValuesMethod · 0.80
CloseMethod · 0.65
DimensionMethod · 0.65
ColMethod · 0.65
InsertColMethod · 0.65
RowMethod · 0.65
InsertRowMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…