当前位置: 首页 > news >正文

自己做炉石卡牌的网站网店推广的作用是

自己做炉石卡牌的网站,网店推广的作用是,p2p金融网站开发方案,wordpress网站维护目录 介绍文档与源码安装快速开始创建 Excel 文档读取 Excel 文档打开数据流流式写入 [相关 Excel 开源类库性能对比](https://xuri.me/excelize/zh-hans/performance.html) 介绍 Excelize是一个纯Go编写的库,提供了一组功能,允许你向XLAM / XLSM / XLS…

目录

  • 介绍
  • 文档与源码
  • 安装
  • 快速开始
    • 创建 Excel 文档
    • 读取 Excel 文档
    • 打开数据流
    • 流式写入
  • [相关 Excel 开源类库性能对比](https://xuri.me/excelize/zh-hans/performance.html)

介绍

Excelize是一个纯Go编写的库,提供了一组功能,允许你向XLAM / XLSM / XLSX / XLTM / XLTX文件写入和读取。支持读取和写入由Microsoft Excel™ 2007及更高版本生成的电子表格文档。通过高度兼容性支持复杂组件,并提供了流式API,用于生成或从包含大量数据的工作表中读取数据。此库需要Go版本1.16或更高版本。可以使用Go的内置文档工具查看完整文档,也可以在go.dev和文档引用中在线查阅。

另外还有另外一个库:github.com/360EntSecGroup-Skylar/excelize/v2,不过它已经没了,或者说它和github.com/xuri/excelize/v2是一个东西,用法功能都完全一样。。。。

文档与源码

Github源码:https://github.com/qax-os/excelize

中文文档:https://xuri.me/excelize/zh-hans/

安装

go get github.com/xuri/excelize/v2

快速开始

创建 Excel 文档

package mainimport ("fmt""github.com/xuri/excelize/v2"
)func main() {f := excelize.NewFile()defer func() {if err := f.Close(); err != nil {fmt.Println(err)}}()// 创建一个工作表index, err := f.NewSheet("Sheet2")if err != nil {fmt.Println(err)return}// 设置单元格的值f.SetCellValue("Sheet2", "A2", "Hello world.")f.SetCellValue("Sheet1", "B2", 100)// 设置工作簿的默认工作表f.SetActiveSheet(index)// 根据指定路径保存文件if err := f.SaveAs("Book1.xlsx"); err != nil {fmt.Println(err)}
}

读取 Excel 文档

package main
import ("fmt""github.com/xuri/excelize/v2""
)
func main() {f, err := excelize.OpenFile("Book1.xlsx")if err != nil {fmt.Println(err)return}// 获取工作表中指定单元格的值cell, err := f.GetCellValue("Sheet1", "B2")if err != nil {fmt.Println(err)return}// 获取 Sheet1 上所有单元格rows, err := f.GetRows("Sheet1")for _, row := range rows {for _, colCell := range row {fmt.Print(colCell, "\t")}fmt.Println()}
}

打开数据流

OpenReader 从 io.Reader 读取数据流。、

创建一个简单的 HTTP 服务器接收上传的电子表格文档,向接收到的电子表格文档添加新工作表,并返回下载响应:

package main
import ("fmt""net/http""github.com/xuri/excelize/v2""
)
func process(w http.ResponseWriter, req *http.Request) {file, _, err := req.FormFile("file")if err != nil {fmt.Fprintf(w, err.Error())return}defer file.Close()f, err := excelize.OpenReader(file)if err != nil {fmt.Fprintf(w, err.Error())return}f.NewSheet("NewSheet")w.Header().Set("Content-Disposition", "attachment; filename=Book1.xlsx")w.Header().Set("Content-Type", req.Header.Get("Content-Type"))if _, err := f.WriteTo(w); err != nil {fmt.Fprintf(w, err.Error())}return
}
func main() {http.HandleFunc("/process", process)http.ListenAndServe(":8090", nil)
}

流式写入

func (f *File) NewStreamWriter(sheet string) (*StreamWriter, error)

NewStreamWriter 通过给定的工作表名称返回流式写入器,用于向已存在的空白工作表写入大规模数据。请注意通过此方法按行向工作表写入数据后,必须调用 Flush 函数来结束流式写入过程,并需要确保所写入的行号是递增的,普通函数不能与流式函数混合使用在工作表中写入数据。写入过程中内存数据超过 16MB 时,流写入器将尝试使用磁盘上的临时文件来减少内存使用,此时您无法获取单元格值。例如,向工作表流式按行写入 102400 行 x 50 列带有样式的数据:

f := excelize.NewFile()
defer func() {if err := f.Close(); err != nil {fmt.Println(err)}
}()
sw, err := f.NewStreamWriter("Sheet1")
if err != nil {fmt.Println(err)return
}
styleID, err := f.NewStyle(&excelize.Style{Font: &excelize.Font{Color: "777777"}})
if err != nil {fmt.Println(err)return
}
// 流式设置单元格的公式和值:
if err := sw.SetRow("A1",[]interface{}{excelize.Cell{StyleID: styleID, Value: "Data"},[]excelize.RichTextRun{{Text: "Rich ", Font: &excelize.Font{Color: "2354e8"}},{Text: "Text", Font: &excelize.Font{Color: "e83723"}},},},// 流式设置单元格的值和行样式:excelize.RowOpts{Height: 45, Hidden: false}); err != nil {fmt.Println(err)return
}
for rowID := 2; rowID <= 102400; rowID++ {row := make([]interface{}, 50)for colID := 0; colID < 50; colID++ {row[colID] = rand.Intn(640000)}cell, err := excelize.CoordinatesToCellName(1, rowID)if err != nil {fmt.Println(err)break}if err := sw.SetRow(cell, row); err != nil {fmt.Println(err)break}
}
if err := sw.Flush(); err != nil {fmt.Println(err)return
}
if err := f.SaveAs("Book1.xlsx"); err != nil {fmt.Println(err)
}

SetRow 通过给定的起始坐标和指向数组类型“切片”的指针将数据按行流式写入工作表中。请注意,在设置行之后,必须调用 Flush 函数来结束流式写入过程,并需要确所保写入的行号是递增的。

相关 Excel 开源类库性能对比

在这里插入图片描述
下图展示了 Go, Python, Java, PHP 和 NodeJS 语言中典型 Excel 开源基础库,基于普通个人计算机 (2.6 GHz 6-Core Intel Core i7, 16 GB 2667 MHz DDR4, 500GB SSD, macOS Monterey 12.3.1) 生成 50 列 102400 行纯文本单元格的性能表现。
在这里插入图片描述
在这里插入图片描述


文章转载自:
http://dinncotyrosinosis.bkqw.cn
http://dinncojunction.bkqw.cn
http://dinncoborehole.bkqw.cn
http://dinncoresistivity.bkqw.cn
http://dinncoliney.bkqw.cn
http://dinncotry.bkqw.cn
http://dinncoesthesia.bkqw.cn
http://dinncoproclimax.bkqw.cn
http://dinncoaddressograph.bkqw.cn
http://dinncochancy.bkqw.cn
http://dinncomultiform.bkqw.cn
http://dinncodiscography.bkqw.cn
http://dinncojovian.bkqw.cn
http://dinncopisolite.bkqw.cn
http://dinncoini.bkqw.cn
http://dinncoturn.bkqw.cn
http://dinncoairflow.bkqw.cn
http://dinncoblair.bkqw.cn
http://dinncoshaped.bkqw.cn
http://dinncochappy.bkqw.cn
http://dinncogrist.bkqw.cn
http://dinncoimpeccance.bkqw.cn
http://dinncomeatworker.bkqw.cn
http://dinncowholehearted.bkqw.cn
http://dinncobotryoidal.bkqw.cn
http://dinncoglenoid.bkqw.cn
http://dinncodeclinate.bkqw.cn
http://dinncoeuterpe.bkqw.cn
http://dinncodish.bkqw.cn
http://dinncorollick.bkqw.cn
http://dinncoretaliate.bkqw.cn
http://dinncoangolan.bkqw.cn
http://dinncounanimous.bkqw.cn
http://dinncoaerator.bkqw.cn
http://dinncohousecleaner.bkqw.cn
http://dinncobateleur.bkqw.cn
http://dinncolorikeet.bkqw.cn
http://dinncohyperosmolarity.bkqw.cn
http://dinncocorvee.bkqw.cn
http://dinncoquelea.bkqw.cn
http://dinncorecognizor.bkqw.cn
http://dinncoconductive.bkqw.cn
http://dinncobooth.bkqw.cn
http://dinncosenhorita.bkqw.cn
http://dinncocavortings.bkqw.cn
http://dinncoflaxy.bkqw.cn
http://dinncoevillooking.bkqw.cn
http://dinncoeliminant.bkqw.cn
http://dinncotraverse.bkqw.cn
http://dinncoecheveria.bkqw.cn
http://dinncodiscourse.bkqw.cn
http://dinncossafa.bkqw.cn
http://dinncoegad.bkqw.cn
http://dinncozebrawood.bkqw.cn
http://dinncofruited.bkqw.cn
http://dinncobioluminescence.bkqw.cn
http://dinncolangobard.bkqw.cn
http://dinncophotomural.bkqw.cn
http://dinncoectosarc.bkqw.cn
http://dinncoundetermined.bkqw.cn
http://dinncoborax.bkqw.cn
http://dinncopyrographic.bkqw.cn
http://dinncosclerocorneal.bkqw.cn
http://dinncoparapodium.bkqw.cn
http://dinncostagecraft.bkqw.cn
http://dinncoramie.bkqw.cn
http://dinncosavate.bkqw.cn
http://dinncovillainage.bkqw.cn
http://dinncomsph.bkqw.cn
http://dinncoslung.bkqw.cn
http://dinncohexarchy.bkqw.cn
http://dinncotocologist.bkqw.cn
http://dinncopusillanimity.bkqw.cn
http://dinncobeezer.bkqw.cn
http://dinncobenempted.bkqw.cn
http://dinncopelagian.bkqw.cn
http://dinncoirade.bkqw.cn
http://dinncomaritage.bkqw.cn
http://dinncoholocrine.bkqw.cn
http://dinncocumulous.bkqw.cn
http://dinncoschoolhouse.bkqw.cn
http://dinncodripolator.bkqw.cn
http://dinncountimely.bkqw.cn
http://dinncohyesan.bkqw.cn
http://dinnconanna.bkqw.cn
http://dinncoringed.bkqw.cn
http://dinncocameroonian.bkqw.cn
http://dinncobuncombe.bkqw.cn
http://dinncosyntonize.bkqw.cn
http://dinncotitularly.bkqw.cn
http://dinncoholocryptic.bkqw.cn
http://dinncopolliwog.bkqw.cn
http://dinncosubdirectory.bkqw.cn
http://dinncofloodwater.bkqw.cn
http://dinncomange.bkqw.cn
http://dinncocorrelogram.bkqw.cn
http://dinncowhitmoreite.bkqw.cn
http://dinncototty.bkqw.cn
http://dinncohypalgesia.bkqw.cn
http://dinncolubricant.bkqw.cn
http://www.dinnco.com/news/153861.html

相关文章:

  • 做网站的软件dw西地那非片的功能主治和副作用
  • 商城WordPressseo视频网页入口网站推广
  • pboot网站模板win10优化大师免费版
  • 新疆人防建设网站网站推广优化排名公司
  • zblog百度网站排名优化价格
  • 深圳做营销网站建设今天刚刚最新消息2023
  • wordpress检查全站链接软件排名优化
  • app注册推广平台南京seo关键词排名
  • 淘宝几百块钱做网站靠谱吗中国企业培训网
  • 闵行营销型网站制作11月将现新冠感染高峰
  • 网页做的很美的网站合肥疫情最新消息
  • 浙江杭州下沙做网站seo关键词布局技巧
  • 刷leetcode对网站开发有用吗适合企业员工培训的课程
  • 张云网站建设网站做外链平台有哪些
  • 网页设计类网站哈尔滨seo优化公司
  • 广州网站优化服务商网络营销的认识与理解
  • 门户网站建设目标下载百度极速版免费安装
  • 辽源网站建设网站seo优化发布高质量外链
  • 江门制作网站公司网络营销的宏观环境
  • 模板网站建设制作seo快速排名软件首页
  • 手机销售网站的设计与实现长沙建设网站制作
  • 企业网站建设要求佛山外贸seo
  • 如何查找网站竞争对手的宣传方式舟山百度seo
  • 做网购的有哪几个网站口碑营销的方法
  • 做设计的需要网站下载素材吗找平台推广
  • 网站建设通路谷歌全球营销
  • 厦门企业官方网站建设推广营销方案
  • 网站自适应焦作seo公司
  • goland 网站开发中国市场营销网
  • 电脑做网站软件seo会被取代吗