commit
539786826c
7
col.go
7
col.go
@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -53,13 +54,19 @@ func (xf *XfRk) String(wb *WorkBook) string {
|
|||||||
fNo := wb.Xfs[idx].formatNo()
|
fNo := wb.Xfs[idx].formatNo()
|
||||||
if fNo >= 164 { // user defined format
|
if fNo >= 164 { // user defined format
|
||||||
if formatter := wb.Formats[fNo]; formatter != nil {
|
if formatter := wb.Formats[fNo]; formatter != nil {
|
||||||
|
if (strings.Contains(formatter.str, "#") || strings.Contains(formatter.str, ".00")){
|
||||||
|
//If format contains # or .00 then this is a number
|
||||||
|
return xf.Rk.String()
|
||||||
|
}else{
|
||||||
i, f, isFloat := xf.Rk.number()
|
i, f, isFloat := xf.Rk.number()
|
||||||
if !isFloat {
|
if !isFloat {
|
||||||
f = float64(i)
|
f = float64(i)
|
||||||
}
|
}
|
||||||
t := timeFromExcelTime(f, wb.dateMode == 1)
|
t := timeFromExcelTime(f, wb.dateMode == 1)
|
||||||
|
|
||||||
return yymmdd.Format(t, formatter.str)
|
return yymmdd.Format(t, formatter.str)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// see http://www.openoffice.org/sc/excelfileformat.pdf Page #174
|
// see http://www.openoffice.org/sc/excelfileformat.pdf Page #174
|
||||||
} else if 14 <= fNo && fNo <= 17 || fNo == 22 || 27 <= fNo && fNo <= 36 || 50 <= fNo && fNo <= 58 { // jp. date format
|
} else if 14 <= fNo && fNo <= 17 || fNo == 22 || 27 <= fNo && fNo <= 36 || 50 <= fNo && fNo <= 58 { // jp. date format
|
||||||
i, f, isFloat := xf.Rk.number()
|
i, f, isFloat := xf.Rk.number()
|
||||||
|
10
workbook.go
10
workbook.go
@ -6,6 +6,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"unicode/utf16"
|
"unicode/utf16"
|
||||||
|
"golang.org/x/text/encoding/charmap"
|
||||||
)
|
)
|
||||||
|
|
||||||
//xls workbook type
|
//xls workbook type
|
||||||
@ -160,12 +161,17 @@ func (wb *WorkBook) parseBof(buf io.ReadSeeker, b *bof, pre *bof, offset_pre int
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
func decodeWindows1251(enc []byte) string {
|
||||||
|
dec := charmap.Windows1251.NewDecoder()
|
||||||
|
out, _ := dec.Bytes(enc)
|
||||||
|
return string(out)
|
||||||
|
}
|
||||||
func (w *WorkBook) get_string(buf io.ReadSeeker, size uint16) (res string, err error) {
|
func (w *WorkBook) get_string(buf io.ReadSeeker, size uint16) (res string, err error) {
|
||||||
if w.Is5ver {
|
if w.Is5ver {
|
||||||
var bts = make([]byte, size)
|
var bts = make([]byte, size)
|
||||||
_, err = buf.Read(bts)
|
_, err = buf.Read(bts)
|
||||||
res = string(bts)
|
res = decodeWindows1251(bts)
|
||||||
|
//res = string(bts)
|
||||||
} else {
|
} else {
|
||||||
var richtext_num = uint16(0)
|
var richtext_num = uint16(0)
|
||||||
var phonetic_size = uint32(0)
|
var phonetic_size = uint32(0)
|
||||||
|
3
xls.go
3
xls.go
@ -37,7 +37,10 @@ func OpenReader(reader io.ReadSeeker, charset string) (wb *WorkBook, err error)
|
|||||||
for _, file := range dir {
|
for _, file := range dir {
|
||||||
name := file.Name()
|
name := file.Name()
|
||||||
if name == "Workbook" {
|
if name == "Workbook" {
|
||||||
|
if book == nil {
|
||||||
book = file
|
book = file
|
||||||
|
}
|
||||||
|
//book = file
|
||||||
// break
|
// break
|
||||||
}
|
}
|
||||||
if name == "Book" {
|
if name == "Book" {
|
||||||
|
Loading…
Reference in New Issue
Block a user