20
0
Pure Golang xls library -- forked from https://github.com/extrame/xls
Go to file
2015-03-24 13:06:52 +08:00
bof.go init 2015-03-19 17:39:41 +08:00
cell_range.go add hyperlink and formula cell support 2015-03-24 13:06:52 +08:00
col.go add hyperlink and formula cell support 2015-03-24 13:06:52 +08:00
font.go init 2015-03-19 17:39:41 +08:00
format.go init 2015-03-19 17:39:41 +08:00
README.md update readme 2015-03-23 10:06:19 +08:00
row.go add hyperlink and formula cell support 2015-03-24 13:06:52 +08:00
sst.go init 2015-03-19 17:39:41 +08:00
st_xf_data.go init 2015-03-19 17:39:41 +08:00
workbook.go add hyperlink and formula cell support 2015-03-24 13:06:52 +08:00
worksheet.go add hyperlink and formula cell support 2015-03-24 13:06:52 +08:00
xf.go init 2015-03-19 17:39:41 +08:00
xls_test.go add hyperlink and formula cell support 2015-03-24 13:06:52 +08:00
xls.go init 2015-03-19 17:39:41 +08:00

xls

Pure Golang xls library

This is a xls library writen in pure Golang. Almostly it is translated from the libxls library in c.

It has just the reading function without the format.

Basic Usage

  • Use Open function for open file
  • Use OpenReader function for open xls from a reader

These methods will open a workbook object for reading, like

func (w *WorkBook) ReadAllCells() (res [][]string) {
	for _, sheet := range w.Sheets {
		w.PrepareSheet(sheet)
		if sheet.MaxRow != 0 {
			temp := make([][]string, sheet.MaxRow+1)
			for k, row := range sheet.Rows {
				data := make([]string, 0)
				if len(row.Cols) > 0 {
					for _, col := range row.Cols {
						if uint16(len(data)) <= col.LastCol() {
							data = append(data, make([]string, col.LastCol()-uint16(len(data))+1)...)
						}
						str := col.String(w)
						for i := uint16(0); i < col.LastCol()-col.FirstCol()+1; i++ {
							data[col.FirstCol()+i] = str[i]
						}
					}
					temp[k] = data
				}
			}
			res = append(res, temp...)
		}
	}
	return
}