odf icon indicating copy to clipboard operation
odf copied to clipboard

I have some simple suggestions for changes

Open yangyile1990 opened this issue 1 year ago • 0 comments

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
}
  1. cex.PlainText(&bytes.Buffer{}) -> cex.GetPlainText() -> cex.GetRawString()
  2. doc.Table -> doc.Tables
  3. tb.Row -> tb.Rows
  4. row.Cell -> row.Cells
  5. odsFile.ParseContent(&doc) -> doc := odsFile.GetDoc()

Thank you!

yangyile1990 avatar Apr 30 '24 10:04 yangyile1990