From c7f56bc92ad2326fe60f21b32a5fb1c03f013c5a Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Mon, 23 Mar 2015 10:06:19 +0800 Subject: [PATCH] update readme --- README.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/README.md b/README.md index 7399e37..3dabff1 100644 --- a/README.md +++ b/README.md @@ -4,3 +4,37 @@ 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 + } +