yao/excel/each_test.go
Max f0da60f467 feat: Migrate Excel plugin to built-in functionality
Move Excel plugin from external plugin to built-in functionality, including:
- Core Excel file operations (open, close, save)
- Sheet manipulation and cell operations
- Row and column iterators
- Process handlers for Excel operations
- Comprehensive test coverage

This change internalizes Excel manipulation capabilities:
- Read/write operations on cells, rows and columns
- Sheet management and styling
- Cell merging and formula handling
- Coordinate conversion utilities
2025-03-21 20:56:35 +08:00

64 lines
1.2 KiB
Go

package excel
import (
"strings"
"testing"
"github.com/stretchr/testify/assert"
)
func TestEachCols(t *testing.T) {
files := testFiles(t)
h1, err := Open(files["test-01"], false)
if err != nil {
t.Fatal(err)
}
defer Close(h1)
xls, err := Get(h1)
if err != nil {
t.Fatal(err)
}
id, err := xls.OpenColumn("供销存管理表格")
if err != nil {
t.Fatal(err)
}
defer CloseColumn(id)
res := []string{}
for col, err := NextColumn(id); err == nil && col != nil; col, err = NextColumn(id) {
res = append(res, col...)
}
assert.Contains(t, strings.Join(res, ""), "供销存管理表格产品查询")
assert.Contains(t, strings.Join(res, ""), "刘大大")
}
func TestEachRows(t *testing.T) {
files := testFiles(t)
h1, err := Open(files["test-01"], false)
if err != nil {
t.Fatal(err)
}
defer Close(h1)
xls, err := Get(h1)
if err != nil {
t.Fatal(err)
}
id, err := xls.OpenRow("供销存管理表格")
if err != nil {
t.Fatal(err)
}
defer CloseRow(id)
res := []string{}
for row, err := NextRow(id); err == nil && row != nil; row, err = NextRow(id) {
res = append(res, row...)
}
assert.Contains(t, strings.Join(res, ""), "供销存管理表格产品查询")
assert.Contains(t, strings.Join(res, ""), "刘大大")
}