重构项目的实现,优化使用方法与使用逻辑

This commit is contained in:
2026-06-25 00:03:59 +08:00
parent a6e8101e09
commit 6072ec57e8
49 changed files with 1663 additions and 12534 deletions

View File

@@ -3,6 +3,7 @@ package excel
import (
"fmt"
"io"
"os"
"reflect"
"time"
@@ -210,6 +211,16 @@ func (e *Excel) ExportToWriter(w io.Writer, sheetName string, columns []ExportCo
return e.file.Write(w)
}
// ExportToFile 导出数据到文件
func (e *Excel) ExportToFile(filePath, sheetName string, columns []ExportColumn, data interface{}) error {
f, err := os.Create(filePath)
if err != nil {
return fmt.Errorf("failed to create file: %w", err)
}
defer f.Close()
return e.ExportToWriter(f, sheetName, columns, data)
}
// GetFile 获取Excel文件对象高级功能时使用
// 返回excelize.File对象可用于高级操作
//