2026-06-14 15:24:02 +08:00
|
|
|
package excelparse
|
|
|
|
|
|
|
|
|
|
import "errors"
|
|
|
|
|
|
|
|
|
|
var (
|
2026-07-05 08:06:28 +09:00
|
|
|
ErrUnknownFormat = errors.New("unrecognized excel format; supported: 秒账, 领星")
|
|
|
|
|
ErrEmptyFile = errors.New("excel file has no data rows")
|
2026-06-14 15:24:02 +08:00
|
|
|
ErrUnsupportedExt = errors.New("unsupported file extension; use .xls or .xlsx")
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type ParsedProduct struct {
|
2026-07-05 08:06:28 +09:00
|
|
|
ProductName string
|
|
|
|
|
Spec string
|
|
|
|
|
Color string
|
|
|
|
|
ColorNo string
|
|
|
|
|
ProductCode string
|
|
|
|
|
UnitRolls int64
|
|
|
|
|
StockQuantity string
|
|
|
|
|
CostPrice string
|
|
|
|
|
SalesPrice string
|
|
|
|
|
BatchNo string
|
|
|
|
|
YarnRatio string
|
|
|
|
|
WarpWeightGM string
|
|
|
|
|
WeftWeightGM string
|
|
|
|
|
ProductionProcess string
|
|
|
|
|
Remark string
|
2026-06-14 15:24:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type ParseResult struct {
|
2026-07-05 08:06:28 +09:00
|
|
|
Products []ParsedProduct
|
|
|
|
|
ParserName string
|
2026-06-14 15:24:02 +08:00
|
|
|
SkippedRows int
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// FormatParser transforms raw spreadsheet rows into structured products.
|
|
|
|
|
// Each competitor format (秒账, 领星, etc.) implements this interface.
|
|
|
|
|
type FormatParser interface {
|
|
|
|
|
Name() string
|
|
|
|
|
Match(headers []string) bool
|
|
|
|
|
ParseRows(headers []string, rows [][]string) (*ParseResult, error)
|
|
|
|
|
}
|