package xvdoc import ( "bytes" "fmt" ) func exportString(matrix []Matrix) ([]byte, error) { if len(matrix) == 0 { return nil, fmt.Errorf("XVDoc export strings error :: expected not empty martix array") } m := matrix[0] var buf bytes.Buffer for i, v := range m.Cells { buf.Write([]byte(fmt.Sprintf("%v: %v\n", i, v))) } return buf.Bytes(), nil } func exportCSV(matrix []Matrix) ([]byte, error) { if len(matrix) == 0 { return nil, fmt.Errorf("XVDoc export CSV error :: expected not empty martix array") } m := matrix[0] var buf bytes.Buffer for _, v := range m.Cells { for i, k := range v { buf.Write([]byte(fmt.Sprint(k.Val()))) if i < len(v)-1 { buf.WriteByte(';') } } buf.WriteByte('\n') } return buf.Bytes(), nil }