bill-produce-excel.go 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  1. package api
  2. import (
  3. "box-cost/db/model"
  4. "fmt"
  5. "github.com/xuri/excelize/v2"
  6. )
  7. type ProduceBillExcel struct {
  8. Offset int
  9. Row int
  10. Title string //标题
  11. Excel *excelize.File
  12. SheetName string
  13. AlignCenterStyle int
  14. Content *model.ProduceBill
  15. Signatures []*model.Signature
  16. IsPdf string
  17. }
  18. func (b *ProduceBillExcel) drawTitle() error {
  19. b.Row++
  20. marginLeft := excelize.PageMarginLeft(0.15)
  21. startCell := fmt.Sprintf("A%d", b.Row)
  22. endCell := fmt.Sprintf("L%d", b.Row)
  23. // !isPrint
  24. if !b.Content.IsPrint {
  25. endCell = fmt.Sprintf("I%d", b.Row)
  26. marginLeft = excelize.PageMarginLeft(0.4)
  27. b.Excel.SetColWidth(b.SheetName, "A", "B", 16)
  28. b.Excel.SetColWidth(b.SheetName, "C", "H", 10.5)
  29. b.Excel.SetColWidth(b.SheetName, "I", "I", 16)
  30. }
  31. // !!isPdf
  32. if b.IsPdf == "true" {
  33. marginLeft = excelize.PageMarginLeft(0.18)
  34. startCell = fmt.Sprintf("A%d", b.Row)
  35. endCell = fmt.Sprintf("J%d", b.Row)
  36. b.Excel.SetColWidth(b.SheetName, "A", "A", 16)
  37. b.Excel.SetColWidth(b.SheetName, "B", "C", 14)
  38. b.Excel.SetColWidth(b.SheetName, "C", "H", 10)
  39. b.Excel.SetColWidth(b.SheetName, "I", "I", 12)
  40. b.Excel.SetColWidth(b.SheetName, "J", "J", 14)
  41. // !isPrint
  42. if !b.Content.IsPrint {
  43. endCell = fmt.Sprintf("G%d", b.Row)
  44. marginLeft = excelize.PageMarginLeft(0.6)
  45. b.Excel.SetColWidth(b.SheetName, "A", "B", 20)
  46. b.Excel.SetColWidth(b.SheetName, "C", "F", 12)
  47. b.Excel.SetColWidth(b.SheetName, "G", "G", 20)
  48. }
  49. }
  50. b.Excel.SetPageMargins(b.SheetName, marginLeft)
  51. err := b.Excel.MergeCell(b.SheetName, startCell, endCell)
  52. if err != nil {
  53. return err
  54. }
  55. style, err := b.Excel.NewStyle(&excelize.Style{
  56. Alignment: &excelize.Alignment{Horizontal: "center", Vertical: "center"},
  57. Font: &excelize.Font{Bold: true, Size: 18}})
  58. if err != nil {
  59. return err
  60. }
  61. err = b.Excel.SetCellStyle(b.SheetName, startCell, startCell, style)
  62. if err != nil {
  63. return err
  64. }
  65. b.Excel.SetRowHeight(b.SheetName, b.Row, 23)
  66. b.Excel.SetCellValue(b.SheetName, startCell, b.Title)
  67. return nil
  68. }
  69. func (b *ProduceBillExcel) drawSubTitles() error {
  70. b.Row++
  71. styleLeft, err := b.Excel.NewStyle(&excelize.Style{
  72. Alignment: &excelize.Alignment{Horizontal: "left", Vertical: "center"},
  73. Font: &excelize.Font{Size: 11}})
  74. if err != nil {
  75. return err
  76. }
  77. styleRight, err := b.Excel.NewStyle(&excelize.Style{
  78. Alignment: &excelize.Alignment{Horizontal: "right", Vertical: "center"},
  79. Font: &excelize.Font{Size: 11}})
  80. if err != nil {
  81. return err
  82. }
  83. var drawLeft = func(rowIndex int, value string) error {
  84. //左边1
  85. left1Cell := fmt.Sprintf("A%d", rowIndex)
  86. err = b.Excel.MergeCell(b.SheetName, left1Cell, fmt.Sprintf("F%d", rowIndex))
  87. if err != nil {
  88. return err
  89. }
  90. err = b.Excel.SetCellStyle(b.SheetName, left1Cell, left1Cell, styleLeft)
  91. if err != nil {
  92. return err
  93. }
  94. b.Excel.SetCellValue(b.SheetName, left1Cell, value)
  95. return nil
  96. }
  97. var drawRight = func(rowIndex int, value string) error {
  98. right1Cell := fmt.Sprintf("G%d", rowIndex)
  99. err = b.Excel.MergeCell(b.SheetName, right1Cell, fmt.Sprintf("L%d", rowIndex))
  100. if err != nil {
  101. return err
  102. }
  103. err = b.Excel.SetCellStyle(b.SheetName, right1Cell, right1Cell, styleRight)
  104. if err != nil {
  105. return err
  106. }
  107. b.Excel.SetCellValue(b.SheetName, right1Cell, value)
  108. return nil
  109. }
  110. // !isPrint
  111. if !b.Content.IsPrint {
  112. drawLeft = func(rowIndex int, value string) error {
  113. //左边1
  114. left1Cell := fmt.Sprintf("A%d", rowIndex)
  115. err = b.Excel.MergeCell(b.SheetName, left1Cell, fmt.Sprintf("E%d", rowIndex))
  116. if err != nil {
  117. return err
  118. }
  119. err = b.Excel.SetCellStyle(b.SheetName, left1Cell, left1Cell, styleLeft)
  120. if err != nil {
  121. return err
  122. }
  123. b.Excel.SetCellValue(b.SheetName, left1Cell, value)
  124. return nil
  125. }
  126. drawRight = func(rowIndex int, value string) error {
  127. right1Cell := fmt.Sprintf("F%d", rowIndex)
  128. err = b.Excel.MergeCell(b.SheetName, right1Cell, fmt.Sprintf("I%d", rowIndex))
  129. if err != nil {
  130. return err
  131. }
  132. err = b.Excel.SetCellStyle(b.SheetName, right1Cell, right1Cell, styleRight)
  133. if err != nil {
  134. return err
  135. }
  136. b.Excel.SetCellValue(b.SheetName, right1Cell, value)
  137. return nil
  138. }
  139. }
  140. // !!isPdf
  141. if b.IsPdf == "true" {
  142. drawLeft = func(rowIndex int, value string) error {
  143. //左边1
  144. left1Cell := fmt.Sprintf("A%d", rowIndex)
  145. err = b.Excel.MergeCell(b.SheetName, left1Cell, fmt.Sprintf("E%d", rowIndex))
  146. if err != nil {
  147. return err
  148. }
  149. err = b.Excel.SetCellStyle(b.SheetName, left1Cell, left1Cell, styleLeft)
  150. if err != nil {
  151. return err
  152. }
  153. b.Excel.SetCellValue(b.SheetName, left1Cell, value)
  154. return nil
  155. }
  156. drawRight = func(rowIndex int, value string) error {
  157. right1Cell := fmt.Sprintf("F%d", rowIndex)
  158. err = b.Excel.MergeCell(b.SheetName, right1Cell, fmt.Sprintf("J%d", rowIndex))
  159. if err != nil {
  160. return err
  161. }
  162. err = b.Excel.SetCellStyle(b.SheetName, right1Cell, right1Cell, styleRight)
  163. if err != nil {
  164. return err
  165. }
  166. b.Excel.SetCellValue(b.SheetName, right1Cell, value)
  167. return nil
  168. }
  169. // !isPrint
  170. if !b.Content.IsPrint {
  171. drawLeft = func(rowIndex int, value string) error {
  172. //左边1
  173. left1Cell := fmt.Sprintf("A%d", rowIndex)
  174. err = b.Excel.MergeCell(b.SheetName, left1Cell, fmt.Sprintf("B%d", rowIndex))
  175. if err != nil {
  176. return err
  177. }
  178. err = b.Excel.SetCellStyle(b.SheetName, left1Cell, left1Cell, styleLeft)
  179. if err != nil {
  180. return err
  181. }
  182. b.Excel.SetCellValue(b.SheetName, left1Cell, value)
  183. return nil
  184. }
  185. drawRight = func(rowIndex int, value string) error {
  186. right1Cell := fmt.Sprintf("C%d", rowIndex)
  187. err = b.Excel.MergeCell(b.SheetName, right1Cell, fmt.Sprintf("G%d", rowIndex))
  188. if err != nil {
  189. return err
  190. }
  191. err = b.Excel.SetCellStyle(b.SheetName, right1Cell, right1Cell, styleRight)
  192. if err != nil {
  193. return err
  194. }
  195. b.Excel.SetCellValue(b.SheetName, right1Cell, value)
  196. return nil
  197. }
  198. }
  199. }
  200. //第一行
  201. drawLeft(b.Row, "类别:"+b.Content.Type)
  202. drawRight(b.Row, "单号:"+b.Content.SerialNumber)
  203. b.Excel.SetRowHeight(b.SheetName, b.Row, 21)
  204. //第二行
  205. drawLeft(b.Row+1, "供应商名称:"+b.Content.Supplier)
  206. timeformat := b.Content.CreateTime.Local().Format("2006年01月02号 15:04:05")
  207. drawRight(b.Row+1, "下单时间:"+timeformat)
  208. b.Excel.SetRowHeight(b.SheetName, b.Row+1, 21)
  209. //第三行
  210. drawLeft(b.Row+2, "产品名称:"+b.Content.ProductName)
  211. status := ""
  212. if b.Content.Status == "complete" {
  213. status = "已完成"
  214. }
  215. if b.Content.Status == "created" {
  216. status = "进行中"
  217. }
  218. drawRight(b.Row+2, "状态:"+status)
  219. b.Excel.SetRowHeight(b.SheetName, b.Row+2, 21)
  220. return nil
  221. }
  222. func (b *ProduceBillExcel) drawTableTitle() error {
  223. b.Row += 3
  224. var drawCol = func(prefix string, value string) error {
  225. left1Cell := fmt.Sprintf("%s%d", prefix, b.Row)
  226. left2Cell := fmt.Sprintf("%s%d", prefix, b.Row+1)
  227. err := b.Excel.MergeCell(b.SheetName, left1Cell, left2Cell)
  228. if err != nil {
  229. return err
  230. }
  231. err = b.Excel.SetCellStyle(b.SheetName, left1Cell, left2Cell, b.AlignCenterStyle)
  232. if err != nil {
  233. return err
  234. }
  235. return b.Excel.SetCellValue(b.SheetName, left1Cell, value)
  236. }
  237. var drawCol2 = func(prefix string, value1 string, value2 string) error {
  238. left1Cell := fmt.Sprintf("%s%d", prefix, b.Row)
  239. left2Cell := fmt.Sprintf("%s%d", prefix, b.Row+1)
  240. err := b.Excel.SetCellStyle(b.SheetName, left1Cell, left2Cell, b.AlignCenterStyle)
  241. if err != nil {
  242. return err
  243. }
  244. b.Excel.SetCellValue(b.SheetName, left1Cell, value1)
  245. b.Excel.SetCellValue(b.SheetName, left2Cell, value2)
  246. return nil
  247. }
  248. // !isPrint
  249. if !b.Content.IsPrint {
  250. // !!isPdf
  251. if b.IsPdf == "true" {
  252. drawCol("A", "加工项目")
  253. drawCol("B", "规格")
  254. drawCol("C", "下单数量")
  255. drawCol2("D", "单价", "元/张")
  256. drawCol("E", "预算金额")
  257. drawCol("F", "交货时间")
  258. drawCol("G", "备注")
  259. } else {
  260. drawCol("A", "加工项目")
  261. drawCol("B", "规格")
  262. drawCol("C", "下单数量")
  263. drawCol("D", "完成数量")
  264. drawCol2("E", "单价", "元/张")
  265. drawCol("F", "预算金额")
  266. drawCol("G", "实际金额")
  267. drawCol("H", "交货时间")
  268. drawCol("I", "备注")
  269. }
  270. } else {
  271. // !!isPdf
  272. if b.IsPdf == "true" {
  273. drawCol("A", "加工项目")
  274. drawCol("B", "规格")
  275. drawCol("C", "纸张")
  276. drawCol("D", "来纸尺寸")
  277. drawCol("E", "印刷尺寸")
  278. drawCol("F", "下单数量")
  279. drawCol2("G", "单价", "元/张")
  280. drawCol("H", "预算金额")
  281. drawCol("I", "交货时间")
  282. drawCol("J", "备注")
  283. } else {
  284. drawCol("A", "加工项目")
  285. drawCol("B", "规格")
  286. drawCol("C", "纸张")
  287. drawCol("D", "来纸尺寸")
  288. drawCol("E", "印刷尺寸")
  289. drawCol("F", "下单数量")
  290. drawCol("G", "完成数量")
  291. drawCol2("H", "单价", "元/张")
  292. drawCol("I", "预算金额")
  293. drawCol("J", "实际金额")
  294. drawCol("K", "交货时间")
  295. drawCol("L", "备注")
  296. }
  297. }
  298. return nil
  299. }
  300. func (b *ProduceBillExcel) drawTableContent() error {
  301. b.Row += 2
  302. var DrawRow = func(rowIndex int, values ...string) {
  303. charas := []string{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L"}
  304. // !isPrint
  305. if !b.Content.IsPrint {
  306. charas = []string{"A", "B", "C", "D", "E", "F", "G", "H", "I"}
  307. }
  308. // !!isPdf
  309. if b.IsPdf == "true" {
  310. charas = []string{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J"}
  311. // !isPrint
  312. if !b.Content.IsPrint {
  313. charas = []string{"A", "B", "C", "D", "E", "F", "G"}
  314. }
  315. }
  316. for i, c := range charas {
  317. v := ""
  318. if i < len(values) {
  319. v = values[i]
  320. }
  321. b.Excel.SetCellValue(b.SheetName, fmt.Sprintf("%s%d", c, rowIndex), v)
  322. val2Cel := fmt.Sprintf("%s%d", c, rowIndex)
  323. b.Excel.SetCellStyle(b.SheetName, val2Cel, val2Cel, b.AlignCenterStyle)
  324. b.Excel.SetRowHeight(b.SheetName, rowIndex, 21)
  325. }
  326. }
  327. produces := b.Content.Produces
  328. if len(produces) > 0 {
  329. for _, produce := range produces {
  330. realCount := ""
  331. price := produce.OrderPrice
  332. priceStr := fmt.Sprintf("%.3f", price)
  333. b.FormatToEmpty(&priceStr)
  334. // 预算金额
  335. budgetAmount := fmt.Sprintf("%.3f", produce.OrderPrice*float64(produce.OrderCount))
  336. b.FormatToEmpty(&budgetAmount)
  337. // 实际金额
  338. realPrice := ""
  339. // 实际完成数
  340. realCount = fmt.Sprintf("%d", produce.ConfirmCount)
  341. b.FormatToEmpty(&realCount)
  342. realPrice = fmt.Sprintf("%.3f", produce.OrderPrice*float64(produce.ConfirmCount))
  343. b.FormatToEmpty(&realPrice)
  344. deliveryTime := produce.DeliveryTime.Local().Format("2006-01-02")
  345. // !isPrint
  346. if !b.Content.IsPrint {
  347. // !!isPdf
  348. if b.IsPdf == "true" {
  349. DrawRow(b.Row, produce.Name, produce.Norm, fmt.Sprintf("%d", produce.OrderCount), priceStr, budgetAmount, deliveryTime, produce.Remark)
  350. } else {
  351. DrawRow(b.Row, produce.Name, produce.Norm, fmt.Sprintf("%d", produce.OrderCount), realCount, priceStr, budgetAmount, realPrice, deliveryTime, produce.Remark)
  352. }
  353. } else {
  354. // !!isPdf
  355. if b.IsPdf == "true" {
  356. DrawRow(b.Row, produce.Name, produce.Norm, produce.Paper, produce.PaperSize, produce.PrintSize, fmt.Sprintf("%d", produce.OrderCount), priceStr, budgetAmount, deliveryTime, produce.Remark)
  357. } else {
  358. DrawRow(b.Row, produce.Name, produce.Norm, produce.Paper, produce.PaperSize, produce.PrintSize, fmt.Sprintf("%d", produce.OrderCount), realCount, priceStr, budgetAmount, realPrice, deliveryTime, produce.Remark)
  359. }
  360. }
  361. b.Row++
  362. }
  363. }
  364. return nil
  365. }
  366. func (b *ProduceBillExcel) drawTableFooter() error {
  367. border := []excelize.Border{
  368. {Type: "top", Style: 1, Color: "000000"},
  369. {Type: "left", Style: 1, Color: "000000"},
  370. {Type: "right", Style: 1, Color: "000000"},
  371. {Type: "bottom", Style: 1, Color: "000000"},
  372. }
  373. styleLeft, _ := b.Excel.NewStyle(&excelize.Style{
  374. Alignment: &excelize.Alignment{Horizontal: "left", Vertical: "center"},
  375. Border: border,
  376. })
  377. sendToStartCell := fmt.Sprintf("A%d", b.Row)
  378. sendToEndCell := fmt.Sprintf("G%d", b.Row)
  379. supplierStartCell := fmt.Sprintf("H%d", b.Row)
  380. supplierEndCell := fmt.Sprintf("L%d", b.Row)
  381. // !isPrint
  382. if !b.Content.IsPrint {
  383. sendToEndCell = fmt.Sprintf("F%d", b.Row)
  384. supplierStartCell = fmt.Sprintf("G%d", b.Row)
  385. supplierEndCell = fmt.Sprintf("I%d", b.Row)
  386. }
  387. // !!isPdf
  388. if b.IsPdf == "true" {
  389. sendToEndCell = fmt.Sprintf("E%d", b.Row)
  390. supplierStartCell = fmt.Sprintf("F%d", b.Row)
  391. supplierEndCell = fmt.Sprintf("J%d", b.Row)
  392. // !isPrint
  393. if !b.Content.IsPrint {
  394. sendToEndCell = fmt.Sprintf("D%d", b.Row)
  395. supplierStartCell = fmt.Sprintf("E%d", b.Row)
  396. supplierEndCell = fmt.Sprintf("G%d", b.Row)
  397. }
  398. }
  399. b.Excel.MergeCell(b.SheetName, sendToStartCell, sendToEndCell)
  400. b.Excel.SetCellStyle(b.SheetName, sendToStartCell, sendToEndCell, styleLeft)
  401. b.Excel.SetCellValue(b.SheetName, sendToStartCell, "送货地址:"+b.Content.SendTo)
  402. b.Excel.MergeCell(b.SheetName, supplierStartCell, supplierEndCell)
  403. b.Excel.SetCellStyle(b.SheetName, supplierStartCell, supplierEndCell, styleLeft)
  404. b.Excel.SetCellValue(b.SheetName, supplierStartCell, "供应商签字:")
  405. b.Excel.SetRowHeight(b.SheetName, b.Row, 21)
  406. return nil
  407. }
  408. func (b *ProduceBillExcel) drawTableSignature() error {
  409. b.Row += 2
  410. style1, _ := b.Excel.NewStyle(&excelize.Style{
  411. Alignment: &excelize.Alignment{Horizontal: "center", Vertical: "center"},
  412. // Border: border,
  413. })
  414. // 制单人
  415. billUserCell := fmt.Sprintf("A%d", b.Row+1)
  416. b.Excel.SetCellValue(b.SheetName, billUserCell, "制单人:"+b.Content.UserName)
  417. fontNum := "H"
  418. image1s := "I"
  419. image2s := "K"
  420. image1e := "J"
  421. image2e := "L"
  422. // !isPrint
  423. if !b.Content.IsPrint {
  424. fontNum = "E"
  425. image1s = "F"
  426. image2s = "H"
  427. image1e = "G"
  428. image2e = "I"
  429. }
  430. // !!isPdf
  431. if b.IsPdf == "true" {
  432. fontNum = "F"
  433. image1s = "G"
  434. image2s = "I"
  435. image1e = "H"
  436. image2e = "J"
  437. if !b.Content.IsPrint {
  438. fontNum = "D"
  439. image1s = "E"
  440. image2s = "G"
  441. image1e = "F"
  442. image2e = "G"
  443. }
  444. }
  445. fontCell := fmt.Sprintf("%s%d", fontNum, b.Row)
  446. fontEndCell := fmt.Sprintf("%s%d", fontNum, b.Row+2)
  447. imageCell1 := fmt.Sprintf("%s%d", image1s, b.Row)
  448. imageEndCell1 := fmt.Sprintf("%s%d", image1e, b.Row+2)
  449. imageCell2 := fmt.Sprintf("%s%d", image2s, b.Row)
  450. imageEndCell2 := fmt.Sprintf("%s%d", image2e, b.Row+2)
  451. b.Excel.MergeCell(b.SheetName, fontCell, fontEndCell)
  452. b.Excel.SetCellStyle(b.SheetName, fontCell, fontCell, style1)
  453. b.Excel.SetCellValue(b.SheetName, fontCell, "审核签字:")
  454. // 签字图片1 I10-J12
  455. b.Excel.MergeCell(b.SheetName, imageCell1, imageEndCell1)
  456. b.Excel.SetCellStyle(b.SheetName, imageCell1, imageCell1, style1)
  457. b.Excel.SetCellValue(b.SheetName, imageCell1, "")
  458. // 签字图片2 K10-L12
  459. b.Excel.MergeCell(b.SheetName, imageCell2, imageEndCell2)
  460. b.Excel.SetCellStyle(b.SheetName, imageCell2, imageCell1, style1)
  461. b.Excel.SetCellValue(b.SheetName, imageCell2, "")
  462. // 状态为已审核时,签字
  463. if b.Content.Reviewed == 1 {
  464. imageCells := []string{imageCell1, imageCell2}
  465. if len(b.Signatures) > 0 {
  466. for k, sign := range b.Signatures {
  467. b.Excel.AddPicture(b.SheetName, imageCells[k], sign.Path, sign.Format)
  468. }
  469. }
  470. }
  471. b.Excel.SetRowHeight(b.SheetName, b.Row, 21)
  472. return nil
  473. }
  474. func (b *ProduceBillExcel) Draws() {
  475. b.drawTitle()
  476. b.drawSubTitles()
  477. b.drawTableTitle()
  478. b.drawTableContent()
  479. b.drawTableFooter()
  480. b.drawTableSignature()
  481. }
  482. func NewProduceBill(f *excelize.File) *ProduceBillExcel {
  483. border := []excelize.Border{
  484. {Type: "top", Style: 1, Color: "000000"},
  485. {Type: "left", Style: 1, Color: "000000"},
  486. {Type: "right", Style: 1, Color: "000000"},
  487. {Type: "bottom", Style: 1, Color: "000000"},
  488. }
  489. styleLeft, _ := f.NewStyle(&excelize.Style{
  490. Alignment: &excelize.Alignment{Horizontal: "center", Vertical: "center"},
  491. Border: border,
  492. })
  493. b := &ProduceBillExcel{
  494. Title: "中鱼互动加工单",
  495. SheetName: "Sheet1",
  496. Excel: f,
  497. Offset: 0,
  498. AlignCenterStyle: styleLeft,
  499. Signatures: make([]*model.Signature, 0),
  500. }
  501. f.SetColWidth(b.SheetName, "A", "A", 12)
  502. f.SetColWidth(b.SheetName, "B", "K", 9.5)
  503. // f.SetColWidth(b.SheetName, "I", "J", 8)
  504. f.SetColWidth(b.SheetName, "L", "L", 10)
  505. f.SetPageMargins(b.SheetName, excelize.PageMarginTop(0), excelize.PageMarginLeft(0), excelize.PageMarginRight(0))
  506. return b
  507. }
  508. func (b *ProduceBillExcel) FormatToEmpty(str *string) {
  509. if *str == "0" || *str == "0.000" {
  510. *str = ""
  511. }
  512. }
  513. func (b *ProduceBillExcel) SetContent(content interface{}) {
  514. b.Content = content.(*model.ProduceBill)
  515. }
  516. func (b *ProduceBillExcel) SetTitle(title string) {
  517. b.Title = title
  518. }
  519. func (b *ProduceBillExcel) SetRow(row int) {
  520. b.Row = row
  521. }
  522. func (b *ProduceBillExcel) SetIsPdf(isPdf string) {
  523. b.IsPdf = isPdf
  524. }
  525. func (b *ProduceBillExcel) GetRow() int {
  526. return b.Row
  527. }
  528. func (b *ProduceBillExcel) SetSignatures(sign interface{}) {
  529. b.Signatures = sign.([]*model.Signature)
  530. }