fix bug
This commit is contained in:
parent
f02a04cbdd
commit
79987c0cd7
28
README.md
28
README.md
@ -17,31 +17,5 @@ It has just the reading function without the format.
|
|||||||
* Use **Open** function for open file
|
* Use **Open** function for open file
|
||||||
* Use **OpenReader** function for open xls from a reader
|
* Use **OpenReader** function for open xls from a reader
|
||||||
|
|
||||||
These methods will open a workbook object for reading, like
|
* Follow the example in GODOC
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -115,14 +115,15 @@ func (wb *WorkBook) parseBof(buf io.ReadSeeker, b *bof, pre *bof, offset_pre int
|
|||||||
var size uint16
|
var size uint16
|
||||||
var i = 0
|
var i = 0
|
||||||
for ; i < int(info.Count); i++ {
|
for ; i < int(info.Count); i++ {
|
||||||
if err := binary.Read(buf_item, binary.LittleEndian, &size); err == nil {
|
var err error
|
||||||
|
if err = binary.Read(buf_item, binary.LittleEndian, &size); err == nil {
|
||||||
var str string
|
var str string
|
||||||
str, err = wb.get_string(buf_item, size)
|
str, err = wb.get_string(buf_item, size)
|
||||||
wb.sst[i] = wb.sst[i] + str
|
wb.sst[i] = wb.sst[i] + str
|
||||||
|
}
|
||||||
|
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
break
|
break
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
offset = i
|
offset = i
|
||||||
|
@ -7,10 +7,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestOpen(t *testing.T) {
|
func TestOpen(t *testing.T) {
|
||||||
if xlFile, err := Open("expenses.xls", "utf-8"); err == nil {
|
if xlFile, err := Open("t1.xls", "utf-8"); err == nil {
|
||||||
if sheet1 := xlFile.GetSheet(0); sheet1 != nil {
|
if sheet1 := xlFile.GetSheet(0); sheet1 != nil {
|
||||||
fmt.Println("Total Lines ", sheet1.MaxRow, sheet1.Name)
|
fmt.Println("Total Lines ", sheet1.MaxRow, sheet1.Name)
|
||||||
for i := 0; i <= int(sheet1.MaxRow); i++ {
|
for i := 265; i <= 267; i++ {
|
||||||
fmt.Printf("row %v point %v \n", i, sheet1.Row(i))
|
fmt.Printf("row %v point %v \n", i, sheet1.Row(i))
|
||||||
if sheet1.Row(i) == nil {
|
if sheet1.Row(i) == nil {
|
||||||
continue
|
continue
|
||||||
@ -18,6 +18,7 @@ func TestOpen(t *testing.T) {
|
|||||||
row := sheet1.Row(i)
|
row := sheet1.Row(i)
|
||||||
for index := row.FirstCol(); index < row.LastCol(); index++ {
|
for index := row.FirstCol(); index < row.LastCol(); index++ {
|
||||||
fmt.Println(index, "==>", row.Col(index), " ")
|
fmt.Println(index, "==>", row.Col(index), " ")
|
||||||
|
fmt.Printf("%T\n", row.cols[uint16(index)])
|
||||||
}
|
}
|
||||||
// col1 := .Cols[0]
|
// col1 := .Cols[0]
|
||||||
// col2 := sheet1.Row(uint16(i)].Cols[1]
|
// col2 := sheet1.Row(uint16(i)].Cols[1]
|
||||||
|
Loading…
Reference in New Issue
Block a user