odf
odf copied to clipboard
I have some simple suggestions for changes
func GetLinesIdxTxtMaps(odsFile *ods.File, tableIndex int) ([]map[int]string, error) {
var doc ods.Doc
if err := odsFile.ParseContent(&doc); err != nil {
return nil, errors.WithMessage(err, "wrong")
}
if len(doc.Table) < tableIndex {
return nil, errors.Errorf("TABLE SIZE IS %d BUT INDEX IS %d", len(doc.Table), tableIndex)
}
var tb = doc.Table[tableIndex]
var results = make([]map[int]string, 0, len(tb.Row))
for _, row := range tb.Row {
var mp = make(map[int]string, len(row.Cell))
for idx, cex := range row.Cell {
mp[idx] = cex.PlainText(&bytes.Buffer{})
}
results = append(results, mp)
}
return results, nil
}
- cex.PlainText(&bytes.Buffer{}) -> cex.GetPlainText() -> cex.GetRawString()
- doc.Table -> doc.Tables
- tb.Row -> tb.Rows
- row.Cell -> row.Cells
- odsFile.ParseContent(&doc) -> doc := odsFile.GetDoc()
Thank you!