Giter Club home page Giter Club logo

xls's Introduction

xls

GoDoc

Pure Golang xls library writen by Rongshu Tech (chinese), based on libxls.

Thanks for contributions from Tamás Gulácsi @tgulacsi, @flyin9.

Basic Usage

  • Use Open function for open file

  • Use OpenWithCloser function for open file and use the return value closer for close file

  • Use OpenReader function for open xls from a reader, you should close related file in your own code

  • Follow the example in GoDoc

xls's People

Contributors

extrame avatar korv1982 avatar sergeilem avatar simon3z avatar sstask avatar technix86 avatar tgulacsi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xls's Issues

Garbles values

Look at the output starting at B24126_036 for Seq99.xls with this reproducible test case:

B24126_033      DETAILED OCCUPATION FOR THE FULL-TIME, YEAR-ROUND CIVILIAN EMPLOYED FEMALE POPULATION 16 YEARS AND OVER% Buyers and purchasing agents, farm products
B24126_034      DETAILED OCCUPATION FOR THE FULL-TIME, YEAR-ROUND CIVILIAN EMPLOYED FEMALE POPULATION 16 YEARS AND OVER% Wholesale and retail buyers, except farm products
B24126_035      DETAILED OCCUPATION FOR THE FULL-TIME, YEAR-ROUND CIVILIAN EMPLOYED FEMALE POPULATION 16 YEARS AND OVER% Purchasing agents, except wholesale, retail, and farm products
B24126_036      䕄䅔䱉䑅传䍃偕呁佉⁎但⁒䡔⁅商䱌吭䵉ⱅ夠䅅ⵒ佒乕⁄䥃䥖䥌乁䔠偍佌䕙⁄䕆䅍䕌倠偏䱕呁佉⁎㘱夠䅅卒䄠䑎传䕖╒䌠慬浩⁳摡番瑳牥ⱳ愠灰慲獩牥ⱳ攠慸業敮獲‬湡⁤湩敶瑳杩瑡牯米䕄䅔䱉䑅传䍃偕呁佉⁎但⁒䡔⁅商䱌吭䵉ⱅ 夠䅅ⵒ佒乕⁄䥃䥖䥌乁䔠偍佌䕙⁄䕆䅍䕌倠偏䱕呁佉⁎㘱夠䅅卒䄠䑎传䕖╒䌠浯汰慩据⁥景楦散獲x䐀呅䥁䕌⁄䍏啃䅐䥔乏䘠剏吠䕈䘠䱕ⵌ䥔䕍‬

数值读取错误

读取-3244847.30 会变成 7492570.94

-1184955 -> 1072556869
-1487365 -> 1072254459

Cant read integer numbers

There is an error in col.go, func (rk RK) number() (intNum int64, floatNum float64, isFloat bool).
Last return must be "return int64(val), 0, false", otherwise function always returns 0 if number stored in cell is integer.

func (rk RK) number() (intNum int64, floatNum float64, isFloat bool) {
multiplied := rk & 1
isInt := rk & 2
val := rk >> 2
if isInt == 0 {
isFloat = true
floatNum = math.Float64frombits(uint64(val) << 34)
if multiplied != 0 {
floatNum = floatNum / 100
}
return
}
if multiplied !=0 {
isFloat = true
floatNum = float64(val)/100
return
}
return int64(val), 0, false
}

formula Read

dear all:
when i test read a .xls file,it has some formula cells but the result is "",
if anyone has method please tell me.

Shouldn't the Library Close the File When Done?

I have been using this library and it seems to work as expected on MacOSX. However, If I cross compile and run my final program on Windows 7 32 bits, I run into a problem where XLS files that I open with this library cannot be edited by other programs.

Example: If I open an XLS file using my software (unless I quit my software) I am unable to edit the file from Excel.

I think this could be solved by exporting a xls.Close that would allow me to defer xls.Close() so that the file is closed once I am done with it. Does this make sense?

Problem reading date

Can you please replace in col.go in func (xf *XfRk) String(wb *WorkBook) string format "2006.01" to time.RFC3339. Otherwise all dates reads without day of month.

Numbers with some special formats reads as date

When user uses specific format for number, for example format "# ##0.00_ ;[Red]-# ##0.00" (users love this format), this number will be read as date.
This is because XfRk.String() reads as date all numbers with formatNo>=164 and above format have formatNo=190.
It would be better to check format string and if it contains "#" or ".00", read it as a number.

col.go:

func (xf *XfRk) String(wb *WorkBook) string {
	idx := int(xf.Index)
	if len(wb.Xfs) > idx {
		fNo := wb.Xfs[idx].formatNo()
		if fNo >= 164 { // user defined format
			if fomt := wb.Formats[fNo]; fomt != nil {
				if (strings.Contains(fomt.str, "#") || strings.Contains(fomt.str, ".00")){
					//If format contains # or .00 then this is a number
					return xf.Rk.String()					
				}else{
					i, f, isFloat := xf.Rk.number()
					if !isFloat {
						f = float64(i)
					}
					t := timeFromExcelTime(f, wb.dateMode == 1)

					return t.Format(time.RFC3339) //TODO it should be international and format as the describled style
				}
			}
			// see http://www.openoffice.org/sc/excelfileformat.pdf
		} 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()
			if !isFloat {
				f = float64(i)
			}
			t := timeFromExcelTime(f, wb.dateMode == 1)
			return t.Format(time.RFC3339) //TODO it should be international
		}
	}
	return xf.Rk.String()
}

Also extra import needed (strings).

Or you can implement more precise heuristics, take a look at is_date_format_string function from python's xlrd here https://github.com/python-excel/xlrd/blob/master/xlrd/formatting.py (line 457).

Wrong Time Parsing

When i try to read out a col, that is formated as time, than i get wrong output depending on what default float value the time has. When the floating point number is periodic, like 0.340277777 for 8:10, than everything is fine. But when the number is f.e. 0,75 for 18:00, than i get the string "h:12;@" as output.

result

Formula execution ?

Hi,

Just wondering, does this lib execute cell formulas and return the results in the cell ?

Many thanks

ReadAllCells函数在excel行数比较多的情况

刚刚试了一下,发现ReadAllCells()的max值设置的比较小的时候,比如说max=100,读取的数据基本是正常的。但是表比较大,有几万行,设置成1万的时候,调用之后发现打印的结果中,前面一点数据正常,后面的几乎每一行的列数据都不完整。
代码大概是这样的:

package main

import (
    "fmt"
    "github.com/extrame/xls"
)

func main() {
    xlsFile, err := xls.Open("./xxx.xls", "utf-8")
    if err != nil {
        panic(err)
    }
    res := xlsFile.ReadAllCells(10000)
    for _, v := range res {
        fmt.Println(v)
    }
}

Data is lost while extracting data from xls

i have 12000 rows data in xls file, i want to read parse, and insert those data to database.
but some data are different/lost from the actual data from excel.

this is my readXlsFile method :

func readXLSFile(filename string) ([][]string, error) {
	result := [][]string{}

	log.Println("Get into readXlsFile")

	xlFile, err := xls.Open(filename, "utf-8")
	if err != nil {
		return nil, err
	}

	sheet1 := xlFile.GetSheet(0)
	//str := ""
	log.Println("Max Row ", int(sheet1.MaxRow))
	for i := 0; i <= (int(sheet1.MaxRow)); i++ {
		row1 := sheet1.Row(i)
		temp := []string{}
		for j := 0; j <= int(row1.LastCol()); j++ {
			temp = append(temp, row1.Col(j))

			log.Println("Max Col", int(row1.LastCol()), "Of row ", i+1)
			//str += fmt.Sprintf("column %d data = %s ", j+1, row1.Col(j))
		}
		//log.Printf("row %d data : %s \n", i+1, str)
		//str = ""
		result = append(result, temp)
	}

	return result, nil
}

and here is my log that show the different data from my xls file :

2018/03/12 19:24:24 service.inquiry.go:4557: row 1836 data : column 1 data = :61:171218C59000NMSC column 2 data =   
2018/03/12 19:24:24 service.inquiry.go:4557: row 1837 data : column 1 data = :86: column 2 data =  column 3 data =  column 4 data =  column 5 data =  column 6 data =  column 7 data =  column 8 data =  column 9 data =  column 10 data =  column 11 data =  column 12 data = PLS10299 column 13 data =  column 14 data = 22162- column 15 data =   
2018/03/12 19:24:24 service.inquiry.go:4557: row 1838 data : column 1 data = :61:171218D300NMSC column 2 data =   
2018/03/12 19:24:24 service.inquiry.go:4557: row 1839 data : column 1 data = :86: column 2 data =  column 3 data =  column 4 data =  column 5 data =  column 6 data =  column 7 data =  column 8 data =  column 9 data =  column 10 data =  column 11 data =  column 12 data = PLS10299 column 13 data =  column 14 data = 22162- column 15 data =   
2018/03/12 19:24:24 service.inquiry.go:4557: row 1840 data : column 1 data = :61:171218D700NMSC column 2 data =   
2018/03/12 19:24:24 service.inquiry.go:4557: row 1841 data : column 1 data = :86: column 2 data =  column 3 data =  column 4 data =  column 5 data =  column 6 data =  column 7 data =  column 8 data =  column 9 data =  column 10 data =  column 11 data =  column 12 data = PLS10299 column 13 data =  column 14 data = 22162- column 15 data =   

and this is the actual data from xls file :
image

does anybody know why is this happening, and how to fix it?

Numbered cells are not getting parsed

Hi,

We are parsing xls file, while processing some of the numbered cells, it is not giving the right values and sometimes it is returning the string.

Could you please help us.

Thanks,
SambasivaRao Y

Cannot open .XLS file saved in LibreOffice

Cannot read .XLS file saved in LibreOffice ( Libreoffice.org ). Same file saved in MS Office reads without problems. I tried to diagnose the problem and it seems to me that problem is in "extrame/ole2" package, but I'm not sure.
I would be grateful if you help fix this problem.
Thanks.

Examples XLS.zip

数据量大时会出现错位现象

当读取较大的excel文件时,出现行列错位现象,经过调试,发现是保存SST – Shared String Table存在bug
1.parseBof函数
case 0x3c: // CONTINUE
...
if size > 0 {
str, err = wb.get_string(buf_item, size)
wb.sst[offset_pre] = wb.sst[offset_pre] + str
}
//此处wb.get_string读取返回EOF的情况下,应该退出循环,否则会导致offset_pre空加,最终导致sst索引错位
offset_pre++

2.get_string函数
if flag&0x1 != 0 {
...
} else {
...
if uint16(n) < size {
w.continue_utf16 = size - uint16(n)
err = io.EOF
}

		var bts1 = make([]uint16, size)//此处err为EOF的情况下,make的大小应该取n而不是size,否则获取到的字符串会出现多余的0

[OOM] resource not release

I have a large amount of excel sheets.
so I use a for loop to parse the data of each excel
then I got an OOM

func Foo() {
	for {
		xlFile, err := xls.Open("example.xls", "utf-8")
                // when it done.memory does not free
		if err != nil || xlFile == nil {
			fmt.Println(err)
		}
		sheets := xlFile.NumSheets()
		for i := 0; i < sheets; i++ {
			if sheet := xlFile.GetSheet(i); sheet != nil {
				for i := 0; i <= (int(sheet.MaxRow)); i++ {
					row1 := sheet.Row(i)
					if row1 == nil {
						continue
					}
					for i := row1.FirstCol(); i <= row1.LastCol(); i++ {
						colCell := row1.Col(i)
						fmt.Println(colCell)
					}
				}
			}
		}
	}
}

浮点数读取错误

func (rk RK) String() string {
i, f, isFloat := rk.number()
if isFloat {
return fmt.Sprintf("%.1f", f)
}
return strconv.FormatInt(i, 10)
}
这里有些浮点数的小数点后面第二位开始全部被丢弃了,造成数值错误
为什么要转成int或者float,而不是直接用string呢?

Error reading numbers

You have an error in col.go, in func (rk RK) number() (intNum int64, floatNum float64, isFloat bool).
You forgot one thing. Even if RK's flag "isInt" is 1, you should return float if "multiplied" flag is also 1, because you should divide by 100 before return value.
Thank you for great job.

func (rk RK) number() (intNum int64, floatNum float64, isFloat bool) {
	multiplied := rk & 1
	isInt := rk & 2
	val := rk >> 2
	if isInt == 0 {
		isFloat = true
		floatNum = math.Float64frombits(uint64(val) << 34)
		if multiplied != 0 {
			floatNum = floatNum / 100
		}
		return
	}
        //+++ add lines from here
        if multiplied !=0 {
		isFloat = true
		floatNum = float64(val)/100
                return
        }
        //+++end
	return int64(val), 0, false
}

xls parsing not working in master branch

Hello,

My xls file is not parsed correctly in master branch, but it works if I changed to new_formatter branch.

here is my code

package main

import (
"errors"
"flag"
"fmt"

"github.com/extrame/xls"

)

func main() {
filePath := flag.String("file", "/home/seaguest/Documents/a.xls", "order file")
flag.Parse()

err := updateOrderFromFile(*filePath)
fmt.Println(err)

}

func updateOrderFromFile(path string) error {
xlFile, err := xls.Open(path, "utf-8")
if err != nil {
fmt.Println(err)
return err
}

sheet1 := xlFile.GetSheet(0)
if sheet1 == nil {
	err := errors.New("empty sheet")
	fmt.Println(err)
	return err
}

fmt.Println("Total Lines ", sheet1.MaxRow, sheet1.Name)

fmt.Println(sheet1)

for i := 1; i <= int(sheet1.MaxRow); i++ {
	for ci := sheet1.Row(0).FirstCol(); ci < sheet1.Row(0).LastCol(); ci++ {
		fmt.Println(ci)
		fmt.Println("name---", sheet1.Row(0).Col(ci), "---value-------------->>>>", sheet1.Row(i).Col(ci))

		estimatedEffect := sheet1.Row(i).Col(ci)
		fmt.Println(estimatedEffect)
	}
}
return nil

Here is my xls file

a

8.38
8.38
11.20
3.87

Could anyone explain?

xls 数据量过大会乱码

当XLS文件数据量过大,将有几千条数据将出现乱码。例如,5万5000条数据就会丢失超过5000的数据,数据量大会出现乱码。

xls解析不稳定, 很多解析不出来, 或者解析错误

Hi,

在使用xls解析的过程中, 发现解析的结果很不稳定, 有的时候正常, 有的时候解析不出来, 甚至解析出来错误的数据.

`
package main

import (
	"errors"
	"flag"
	"fmt"

	"github.com/extrame/xls"
)

func main() {
	filePath := flag.String("file", "/root/Downloads/90.xls", "order file")
	flag.Parse()

	xlFile, err := xls.Open(*filePath, "utf-8")
	if err != nil {
		fmt.Println(err)
		return
	}

	sheet1 := xlFile.GetSheet(0)
	if sheet1 == nil {
		err := errors.New("empty sheet")
		fmt.Println(err)
		return
	}

	for i := 1; i <= int(sheet1.MaxRow); i++ {
		for ci := sheet1.Row(0).FirstCol(); ci < sheet1.Row(0).LastCol(); ci++ {
			fmt.Println(ci)
			fmt.Println("name---", sheet1.Row(0).Col(ci), "---value-------------->>>>", sheet1.Row(i).Col(ci))

			estimatedEffect := sheet1.Row(i).Col(ci)
			fmt.Println(estimatedEffect)
			break
		}
	}
	return
}

`
master分支, new_formatter分支都尝试, 不知道是文件格式的问题, 还是用法上面有问题,请帮忙看一下, 谢谢!

xls文件在这里:

https://send.firefox.com/download/c8599f2c29/#qh4niBsKs489Z-TbD59Ydw

Index out of range bug

There's an index out of range bug at col.go:199 (called by row.go:25).

xls/col.go

Lines 198 to 200 in 5397868

func (c *LabelsstCol) String(wb *WorkBook) []string {
return []string{wb.sst[int(c.Sst)]}
}

You should check if int(c.Sst) is within the range of wb.sst. If not, return []string{""}.

Col(i) return empty string even when there has value

When I read the data from xls file with function *func (r Row) Col(i int) string , I got empty string in some rows. I found that because I insert in character in a cell which is expect a number. I open xls file on macbook, and use WPS office.

Format No 49

Hi,

Format #49 is defined (on page 174) as Text and not as Date, so it should not be converted in

func (xf *XfRk) String(wb *WorkBook) string

数字转字符串出现BUG啊

goroutine 1 [running]:
github.com/extrame/xls.(_XfRk).String(0x10ba5f08, 0x10b581e0, 0x0, 0x0)
d:/go/bin/project/src/github.com/extrame/xls/col.go:46 +0x1c9
github.com/extrame/xls.(_MulrkCol).String(0x10b96160, 0x10b581e0, 0x0, 0x0, 0x0)

    d:/go/bin/project/src/github.com/extrame/xls/col.go:104 +0xb8

main.main()
D:/go/bin/project/bin/xlseample.go:26 +0x3e8
exit status 2

code:

func main() {
if xlFile, err := xls.Open("Book1.xls", "utf-8"); err == nil {
if sheet1 := xlFile.GetSheet(0); sheet1 != nil {
fmt.Print("Total Lines ", sheet1.MaxRow, sheet1.Name)
for i := 0 ; i < int(sheet1.MaxRow) ; i++ {
fmt.Printf("row %v point %v \n",i,sheet1.Rows[uint16(i)])
if sheet1.Rows[uint16(i)] == nil {
continue
}
col1 := sheet1.Rows[uint16(i)].Cols[0]
col2 := sheet1.Rows[uint16(i)].Cols[1]
fmt.Printf("\ncol1 %v \nCol2 %v \n",col1.String(xlFile),col2)
}

    }
}

}

Reading Numbers

Hello,

I have a column with a formula to get numbers and i cannot retrieve those numbers:

package main

import (
	"fmt"

	"github.com/extrame/xls"
)

func main() {
	if xlFile, err := xls.Open("file.xls", "utf-8"); err == nil {
		if sheet := xlFile.GetSheet(0); sheet != nil {

			for i := 2; i <= (int(sheet.MaxRow)); i++ {
				row := sheet.Row(i)
				if row != nil {
					col := row.Col(3)
					fmt.Print("\n", col)
				}
			}
		}
	}

}

Everything else (text) i can retrieve

WorkSheet.Row(i int) method panic

WorkSheet.Row(i int) method panic

0<= j < MaxRow ,why it panic

for i := 0; i < xlFile.NumSheets(); i++ {
	if sheet1 := xlFile.GetSheet(i); sheet1 != nil {
		for j := 0; j < (int(sheet1.MaxRow)); j++ {
			row1 := sheet1.Row(j) // panic
			for k := row1.FirstCol(); k < row1.LastCol(); k++ {
				fmt.Print(row1.Col(k), "\t")
			}
			fmt.Print("\n")
		}
	}
}
func (w *WorkSheet) Row(i int) *Row {
	row := w.rows[uint16(i)] // sometimes row is nil
	row.wb = w.wb
	return row
}

"Index out of range" error from ole2 stream_reader

Apologies in advance, because I'm not particularly proficient with Go. I'm having a problem parsing an XLS file. Here's the error:

panic: runtime error: index out of range

goroutine 1 [running]:
github.com/extrame/ole2.(*StreamReader).Read(0xc82006a1e0, 0xc90b242150, 0x4, 0x4, 0xe2300, 0x0, 0x0)
    /Users/samuelstarling/Development/go/src/github.com/extrame/ole2/stream_reader.go:34 +0x3a6
io.ReadAtLeast(0x424328, 0xc82006a1e0, 0xc90b242150, 0x4, 0x4, 0x4, 0x0, 0x0, 0x0)
    /usr/local/Cellar/go/1.5.1/libexec/src/io/io.go:298 +0xe6
io.ReadFull(0x424328, 0xc82006a1e0, 0xc90b242150, 0x4, 0x4, 0x4, 0x0, 0x0)
    /usr/local/Cellar/go/1.5.1/libexec/src/io/io.go:316 +0x62
encoding/binary.Read(0x424328, 0xc82006a1e0, 0x4242d0, 0x2091a0, 0x108b20, 0xc820068590, 0x0, 0x0)
    /usr/local/Cellar/go/1.5.1/libexec/src/encoding/binary/binary.go:216 +0x1336
github.com/extrame/xls.(*WorkBook).Parse(0xc820124000, 0x424350, 0xc82006a1e0)
    /Users/samuelstarling/Development/go/src/github.com/extrame/xls/workbook.go:44 +0x145
github.com/extrame/xls.newWorkBookFromOle2(0x424350, 0xc82006a1e0, 0x424350)
    /Users/samuelstarling/Development/go/src/github.com/extrame/xls/workbook.go:34 +0x127
github.com/extrame/xls.parse(0xc820092000, 0x7eb90, 0x7ed90, 0x137e88, 0x5, 0x0, 0x0, 0x0)
    /Users/samuelstarling/Development/go/src/github.com/extrame/xls/xls.go:46 +0x27c
github.com/extrame/xls.Open(0x161fa0, 0x32, 0x137e88, 0x5, 0x4b27, 0x0, 0x0)
    /Users/samuelstarling/Development/go/src/github.com/extrame/xls/xls.go:12 +0xa6
main.main()
    /Users/samuelstarling/Development/personal/xls-test/test.go:9 +0x48
exit status 2

I'm running code like this:

func main() {
    xlsFile, err := xls.Open("full.xls", "utf-8")
    if err != nil {
        panic(err)
    }
    fmt.Println(xlsFile)
}

Am I doing something wrong, or is there something up with the file?

Thanks!

Library returning "nil" for some cells

Excel Sheet: Google Drive link for the excel sheet

Sample code which is panicing due to nil value.

➜ $?=0 /tmp [ 8:37AM] % cat main.go
package main

import "fmt"
import "github.com/extrame/xls"

func main() {
        if xlFile, err := xls.Open("expenses.xls", "utf-8"); err == nil {
                if sheet1 := xlFile.GetSheet(0); sheet1 != nil {
                        fmt.Print("Total Lines ", sheet1.MaxRow, sheet1.Name)
                        col1 := sheet1.Rows[0].Cols[0]
                        col2 := sheet1.Rows[0].Cols[0]
                        for i := 0; i <= (int(sheet1.MaxRow)); i++ {
                                row1 := sheet1.Rows[uint16(i)]
                                col1 = row1.Cols[0]
                                col2 = row1.Cols[1]
                                fmt.Print("\n", col1.String(xlFile), ",", col2.String(xlFile))
                        }
                }
        }
}

>>>  0s elasped...
➜ $?=0 /tmp [ 8:37AM] % go run main.go
Total Lines 1Transactions
[Sr. No. ],[Date]panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0x243d]

goroutine 1 [running]:
panic(0xb96e0, 0xc42000a110)
        /usr/local/Cellar/go/1.7.3/libexec/src/runtime/panic.go:500 +0x1a1
main.main()
        /tmp/main.go:16 +0x3fd
exit status 2

>>>  0s elasped...
➜ $?=1 /tmp [ 8:37AM] %

数字转换成时间格式的问题

Hi,我遇到一个问题:
image

里面数字读出来的时候会转成时间格式,不是预想的结果,能不能增加一个选项,只输出没有转换的表格内容:

类似这样

func (xf *XfRk) String(wb *WorkBook) string {
idx := int(xf.Index)
if len(wb.Xfs) > idx {
fNo := wb.Xfs[idx].formatNo()
if fNo >= 164 { // user defined format
if fmt := wb.Formats[fNo]; fmt != nil {
i, f, isFloat := xf.Rk.number()
if !isFloat {
f = float64(i)
}
return strconv.FormatFloat(f, 'f', -1, 32)
//t := timeFromExcelTime(f, wb.dateMode == 1)

			//return t.Format(time.RFC3339) //TODO it should be international and format as the describled style
		}
		// see http://www.openoffice.org/sc/excelfileformat.pdf
	} 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()
		if !isFloat {
			f = float64(i)
		}
		return strconv.FormatFloat(f, 'f', -1, 32)
		//t := timeFromExcelTime(f, wb.dateMode == 1)
		//return t.Format("2006.01") //TODO it should be international
	}
}
return xf.Rk.String()

}

我把代码里面的时间格式转换改成了直接输出数字

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.