微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

go-xls 基于 Golang 的 xls 读取类库

程序名称:go-xls

授权协议: GPL

操作系统: 跨平台

开发语言: Google Go

go-xls 介绍

Golang 编写的 xls 读取类库,能够实现 xls 表格的读取功能

部分代码

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
}

go-xls 官网

https://github.com/extrame/xls

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐