Demonstrates how to append cols/rows/sheets.
()
| 360 | |
| 361 | // Demonstrates how to append cols/rows/sheets. |
| 362 | func 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 |
| 400 | func Example_insert() { |
nothing calls this directly
no test coverage detected
searching dependent graphs…