使用 Cells Cloud SDK for Go 将 WORKBOOK 对象导出为 CSV 格式文件
API
POST
https://api.aspose.cloud/v3.0/cells/export
将 WORKBOOK 对象从 Excel 文件导出到 CSV 文件是一项复杂的任务。将 WORKBOOK 导出到 CSV 格式的转换由我们的 Go SDK 执行,同时保留源 WORKBOOK 电子表格的主要结构和逻辑内容。我们的 Go 库是在线将 WORKBOOK 对象导出为 CSV 格式文件的专业解决方案。这个Cloud SDK为Go开发者提供了强大的功能和完美的CSV输出。
Go 中的代码示例,使用 REST API 将电子表格中的 WORKBOOK 导出为 CSV 格式
// For complete examples and data files, please go to https://github.com/aspose-cells-cloud/aspose-cells-cloud-go/
package main
import (
"encoding/base64"
"os"
asposecellscloud "github.com/aspose-cells-cloud/aspose-cells-cloud-go/v22"
)
func main() {
instance := asposecellscloud.NewLightCellsApiService(os.Getenv("ProductClientId"), os.Getenv("ProductClientSecret"))
var files map[string]string
files = make(map[string]string)
files["Book1.xlsx"] = "C:/Book1.xlsx"
files["myDocument.xlsx"] = "C:/myDocument.xlsx"
postExportOpts := new(asposecellscloud.PostExportOpts)
postExportOpts.ObjectType = "workbook"
postExportOpts.Format = "csv"
filesresult, _, err := instance.PostExport(files, postExportOpts)
if err != nil {
return
}
print(filesresult.Files[0].Filename)
originalStringBytes, err1 := base64.StdEncoding.DecodeString(filesresult.Files[0].FileContent)
if err1 != nil {
return
}
f, err2 := os.Create(filesresult.Files[0].Filename)
if err2 != nil {
return
}
_, err3 := f.Write(originalStringBytes)
if err3 != nil {
return
}
f.Close()
}
如何使用 Cells Cloud SDK for Go 将 Excel WORKBOOK 中的对象导出为 CSV
- 注册一个帐户仪表板获取免费API配额和授权详细信息
- 使用您的客户端 ID、客户端密钥、基本 URL 和 API 版本初始化 Cells API。
- 使用 `postExport` 方法检索结果流。
系统要求
- go 版本 go1.13.0 或更高版本