35 lines
870 B
Go
Raw Normal View History

package excelparse
import "errors"
var (
ErrUnknownFormat = errors.New("unrecognized excel format; supported: 秒账, 领星")
ErrEmptyFile = errors.New("excel file has no data rows")
ErrUnsupportedExt = errors.New("unsupported file extension; use .xls or .xlsx")
)
type ParsedProduct struct {
ProductName string
Spec string
Color string
UnitRolls int64
StockQuantity string
CostPrice string
SalesPrice string
Remark string
}
type ParseResult struct {
Products []ParsedProduct
ParserName string
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)
}