| 12345678910111213141516171819202122232425262728293031323334 |
- package xlsx
- // get all raw data from excel
- // output index mean=> sheetIndex ,row ,cell ,value
- // not remove any cells
- func FileToSlice(path string) ([][][]string, error) {
- f, err := OpenFile(path)
- if err != nil {
- return nil, err
- }
- return f.ToSlice()
- }
- // get all raw data from excel
- // output index mean=> sheetIndex ,row ,cell ,value
- // not remove any cells
- func (file *File) ToSlice() (output [][][]string, err error) {
- output = [][][]string{}
- for _, sheet := range file.Sheets {
- s := [][]string{}
- for _, row := range sheet.Rows {
- if row == nil {
- continue
- }
- r := []string{}
- for _, cell := range row.Cells {
- r = append(r, cell.String())
- }
- s = append(s, r)
- }
- output = append(output, s)
- }
- return output, nil
- }
|