Records returns the rows in datatable as string Computes all expressions.
()
| 86 | // Records returns the rows in datatable as string |
| 87 | // Computes all expressions. |
| 88 | func (t *DataTable) Records() [][]string { |
| 89 | if t == nil { |
| 90 | return nil |
| 91 | } |
| 92 | |
| 93 | if err := t.evaluateExpressions(); err != nil { |
| 94 | panic(err) |
| 95 | } |
| 96 | |
| 97 | // visible columns |
| 98 | var cols []int |
| 99 | for i, col := range t.cols { |
| 100 | if col.IsVisible() { |
| 101 | cols = append(cols, i) |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | rows := make([][]string, 0, t.nrows) |
| 106 | for i := 0; i < t.nrows; i++ { |
| 107 | r := make([]string, 0, len(cols)) |
| 108 | for _, pos := range cols { |
| 109 | r = append(r, fmt.Sprintf("%v", t.cols[pos].serie.Get(i))) |
| 110 | } |
| 111 | rows = append(rows, r) |
| 112 | } |
| 113 | return rows |
| 114 | } |
| 115 | |
| 116 | // Rows returns the rows in datatable |
| 117 | // Computes all expressions. |
no test coverage detected