123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- package xvdoc
- import (
- "fmt"
- "io/ioutil"
- "log"
- "testing"
- )
- func TestReport(t *testing.T) {
- if src, err := ioutil.ReadFile("z_report.json"); err == nil {
- if docs, err := FromJSON(src); err == nil {
- log.Println("!!!!!!!", len(docs), docs)
- log.Println("=============================")
- if exp, err := Export("xlsx", docs); err == nil {
- ioutil.WriteFile("report.xlsx", exp, 0660)
- } else {
- log.Println(err)
- }
- } else {
- t.Error(err)
- }
- } else {
- t.Error(err)
- }
- }
- func TestXVDoc(t *testing.T) {
- if src, err := ioutil.ReadFile("z_source.json"); err == nil {
- if docs, err := FromJSON(src); err == nil {
- log.Println("!!!!!!!", len(docs), docs)
- log.Println("=============================")
- if exp, err := Export("xlsx", docs); err == nil {
- ioutil.WriteFile("tmp.xlsx", exp, 0660)
- } else {
- log.Println(err)
- }
- } else {
- t.Error(err)
- }
- } else {
- t.Error(err)
- }
- }
- func TestImage(t *testing.T) {
- if src, err := ioutil.ReadFile("z_image.json"); err == nil {
- if docs, err := FromJSON(src); err == nil {
- log.Println("!!!!!!!", len(docs), docs)
- log.Println("=============================")
- if exp, err := Export("xlsx", docs); err == nil {
- ioutil.WriteFile("tmp.xlsx", exp, 0660)
- } else {
- log.Println(err)
- }
- } else {
- t.Error(err)
- }
- } else {
- t.Error(err)
- }
- }
- func TestXLSXImport(t *testing.T) {
- sheets, err := ImportXLSXFromFile("tmp.xlsx")
- fmt.Println(sheets, "|", err)
- }
- func TestXLSXImportToJSON(t *testing.T) {
- src, err := ImportXLSXToJSONFromFile("tmp.xlsx")
- fmt.Println(string(src), "|", err)
- }
|