plan-summary-excel.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  1. package api
  2. import (
  3. "fmt"
  4. "github.com/xuri/excelize/v2"
  5. )
  6. // 生产成本表
  7. type PlanSummaryExcel struct {
  8. Row int
  9. Title string
  10. Excel *excelize.File
  11. SheetName string
  12. AlignCenterStyle int
  13. Content *SupplierPlanSummary
  14. }
  15. func (b *PlanSummaryExcel) drawTitle() error {
  16. b.Row++
  17. startCell := fmt.Sprintf("A%d", b.Row)
  18. err := b.Excel.MergeCell(b.SheetName, startCell, fmt.Sprintf("P%d", b.Row))
  19. if err != nil {
  20. return err
  21. }
  22. style, err := b.Excel.NewStyle(&excelize.Style{
  23. Alignment: &excelize.Alignment{Horizontal: "center", Vertical: "center", WrapText: true},
  24. Font: &excelize.Font{Bold: true, Size: 18}})
  25. if err != nil {
  26. return err
  27. }
  28. err = b.Excel.SetCellStyle(b.SheetName, startCell, startCell, style)
  29. if err != nil {
  30. return err
  31. }
  32. b.Excel.SetRowHeight(b.SheetName, b.Row, 23)
  33. b.Excel.SetCellValue(b.SheetName, startCell, "汇总表")
  34. return nil
  35. }
  36. func (b *PlanSummaryExcel) drawTableTitle() error {
  37. b.Row++
  38. var drawCol = func(prefix string, value string) error {
  39. left1Cell := fmt.Sprintf("%s%d", prefix, b.Row)
  40. left2Cell := fmt.Sprintf("%s%d", prefix, b.Row+1)
  41. err := b.Excel.MergeCell(b.SheetName, left1Cell, left2Cell)
  42. if err != nil {
  43. return err
  44. }
  45. err = b.Excel.SetCellStyle(b.SheetName, left1Cell, left2Cell, b.AlignCenterStyle)
  46. if err != nil {
  47. return err
  48. }
  49. return b.Excel.SetCellValue(b.SheetName, left1Cell, value)
  50. }
  51. var drawCol2 = func(prefix1 string, prefix2 string, value1 string, value2 string, value3 string) error {
  52. left1Cell := fmt.Sprintf("%s%d", prefix1, b.Row)
  53. left2Cell := fmt.Sprintf("%s%d", prefix2, b.Row)
  54. err := b.Excel.MergeCell(b.SheetName, left1Cell, left2Cell)
  55. if err != nil {
  56. return err
  57. }
  58. if err != nil {
  59. fmt.Println(err)
  60. return err
  61. }
  62. err = b.Excel.SetCellStyle(b.SheetName, left1Cell, left2Cell, b.AlignCenterStyle)
  63. if err != nil {
  64. return err
  65. }
  66. b.Excel.SetCellValue(b.SheetName, left1Cell, value1)
  67. val2Cel := fmt.Sprintf("%s%d", prefix1, b.Row+1)
  68. b.Excel.SetCellStyle(b.SheetName, val2Cel, val2Cel, b.AlignCenterStyle)
  69. b.Excel.SetCellValue(b.SheetName, val2Cel, value2)
  70. val3Cel := fmt.Sprintf("%s%d", prefix2, b.Row+1)
  71. b.Excel.SetCellStyle(b.SheetName, val3Cel, val3Cel, b.AlignCenterStyle)
  72. b.Excel.SetCellValue(b.SheetName, val3Cel, value3)
  73. return nil
  74. }
  75. var drawCol3 = func(prefix1 string, prefix2 string, prefix3 string, value1 string, value2 string, value3 string, value4 string) error {
  76. left1Cell := fmt.Sprintf("%s%d", prefix1, b.Row)
  77. left3Cell := fmt.Sprintf("%s%d", prefix3, b.Row)
  78. err := b.Excel.MergeCell(b.SheetName, left1Cell, left3Cell)
  79. if err != nil {
  80. return err
  81. }
  82. if err != nil {
  83. fmt.Println(err)
  84. return err
  85. }
  86. err = b.Excel.SetCellStyle(b.SheetName, left1Cell, left3Cell, b.AlignCenterStyle)
  87. if err != nil {
  88. return err
  89. }
  90. b.Excel.SetCellValue(b.SheetName, left1Cell, value1)
  91. val2Cel := fmt.Sprintf("%s%d", prefix1, b.Row+1)
  92. b.Excel.SetCellStyle(b.SheetName, val2Cel, val2Cel, b.AlignCenterStyle)
  93. b.Excel.SetCellValue(b.SheetName, val2Cel, value2)
  94. val3Cel := fmt.Sprintf("%s%d", prefix2, b.Row+1)
  95. b.Excel.SetCellStyle(b.SheetName, val3Cel, val3Cel, b.AlignCenterStyle)
  96. b.Excel.SetCellValue(b.SheetName, val3Cel, value3)
  97. val4Cel := fmt.Sprintf("%s%d", prefix3, b.Row+1)
  98. b.Excel.SetCellStyle(b.SheetName, val4Cel, val4Cel, b.AlignCenterStyle)
  99. b.Excel.SetCellValue(b.SheetName, val4Cel, value4)
  100. return nil
  101. }
  102. drawCol("A", "产品名称")
  103. drawCol("B", "产品部件名称")
  104. drawCol2("C", "D", "类型/项目", "类型", "项目")
  105. drawCol("E", "下单数量")
  106. drawCol("F", "实际数量")
  107. drawCol("G", "状态") // 生成订单状态 审核状态 发送状态 完成状态
  108. drawCol("H", "供应商名称")
  109. drawCol("I", "单价")
  110. drawCol3("J", "K", "L", "规格", "厚度(纸克)", "长", "宽")
  111. drawCol("M", "单位")
  112. drawCol("N", "下单单价")
  113. drawCol("O", "预算金额")
  114. drawCol("P", "实际金额")
  115. return nil
  116. }
  117. func (b *PlanSummaryExcel) drawRow(rowIndex int, values ...string) {
  118. charas := []string{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P"}
  119. for i, c := range charas {
  120. v := ""
  121. if i < len(values) {
  122. v = values[i]
  123. }
  124. b.Excel.SetCellValue(b.SheetName, fmt.Sprintf("%s%d", c, rowIndex), v)
  125. val2Cel := fmt.Sprintf("%s%d", c, rowIndex)
  126. b.Excel.SetCellStyle(b.SheetName, val2Cel, val2Cel, b.AlignCenterStyle)
  127. b.Excel.SetRowHeight(b.SheetName, rowIndex, 32)
  128. }
  129. }
  130. func (b *PlanSummaryExcel) drawAllContent() error {
  131. b.Row += 2
  132. // summaryPlans
  133. // 预算金额汇总
  134. var totalBudgetPrice float64 = 0.00
  135. // 实际金额汇总
  136. var totalRealPrice float64 = 0.00
  137. for _, splan := range b.Content.Plans {
  138. planStartRow := b.Row
  139. plan := splan.Plan
  140. comps := plan.Pack.Components
  141. // 预算金额汇总
  142. var planBudgetPrice float64 = 0.00
  143. // 实际金额汇总
  144. var planRealPrice float64 = 0.00
  145. if len(comps) > 0 {
  146. for _, comp := range comps {
  147. var perBudgetPrice float64 = 0.00
  148. var perRealPrice float64 = 0.00
  149. if len(comp.Stages) > 0 {
  150. startRow := b.Row
  151. cates := map[string][]int{}
  152. for _, stage := range comp.Stages {
  153. matHeigth := fmt.Sprintf("%d", stage.BatchSizeHeight)
  154. b.FormatToEmpty(&matHeigth)
  155. matWidth := fmt.Sprintf("%d", stage.BatchSizeWidth)
  156. b.FormatToEmpty(&matWidth)
  157. orderCount := fmt.Sprintf("%d", int(stage.OrderCount))
  158. b.FormatToEmpty(&orderCount)
  159. // 实际数量
  160. realCount := fmt.Sprintf("%d", stage.ConfirmCount)
  161. b.FormatToEmpty(&realCount)
  162. // 单价
  163. price := fmt.Sprintf("%.3f", stage.OrderPrice)
  164. b.FormatToEmpty(&price)
  165. // 预算金额
  166. budgetPrice := fmt.Sprintf("%.3f", stage.OrderPrice*float64(stage.OrderCount))
  167. perBudgetPrice += stage.OrderPrice * float64(stage.OrderCount)
  168. b.FormatToEmpty(&budgetPrice)
  169. // 实际金额
  170. perRealPrice += stage.OrderPrice * float64(stage.ConfirmCount)
  171. realPrice := fmt.Sprintf("%.3f", stage.OrderPrice*float64(stage.ConfirmCount))
  172. b.FormatToEmpty(&realPrice)
  173. unit := stage.Unit
  174. if stage.Unit == "吨" || stage.Unit == "平方米" {
  175. unit = "张"
  176. }
  177. supplierName := ""
  178. if stage.SupplierInfo != nil {
  179. supplierName = stage.SupplierInfo.Name
  180. }
  181. stageType := ""
  182. if stage.BillType > 0 {
  183. stage.Type = stage.BillType
  184. }
  185. if stage.Type == 1 {
  186. stageType = "材料采购"
  187. }
  188. if stage.Type == 2 {
  189. stageType = "工艺"
  190. }
  191. if stage.Type == 3 {
  192. stageType = "成品采购"
  193. }
  194. // 状态
  195. stop := false
  196. stageStatus := ""
  197. if len(stage.BillId) < 1 {
  198. stageStatus = "未生成订单"
  199. stop = true
  200. }
  201. // 审核状态
  202. if !stop {
  203. if splan.Reviewed[stage.BillId] == 1 {
  204. stageStatus = "已审核"
  205. } else {
  206. stageStatus = "未审核"
  207. stop = true
  208. }
  209. }
  210. // 接单状态
  211. if !stop {
  212. if splan.IsAck[stage.BillId] {
  213. stageStatus = "已接单"
  214. } else {
  215. stageStatus = "未接单"
  216. stop = true
  217. }
  218. }
  219. // 完成状态
  220. if splan.State[stage.BillId] == "complete" {
  221. stageStatus = "已完成"
  222. } else if splan.State[stage.BillId] == "created" {
  223. stageStatus = "进行中"
  224. }
  225. b.drawRow(b.Row, "", "", stageType, stage.Name, orderCount, realCount, stageStatus, supplierName, fmt.Sprintf("%.3f元/%s", stage.Price, stage.Unit), stage.Norm, matHeigth, matWidth, unit, price, budgetPrice, realPrice)
  226. if stage.SupplierInfo != nil {
  227. cates[stage.SupplierInfo.Name] = append(cates[stage.SupplierInfo.Name], b.Row)
  228. }
  229. b.Row++
  230. }
  231. for supplierName, cate := range cates {
  232. mergeStartRow := cate[0]
  233. mergeEndRow := cate[len(cate)-1]
  234. b.Excel.MergeCell(b.SheetName, fmt.Sprintf("H%d", mergeStartRow), fmt.Sprintf("H%d", mergeEndRow))
  235. b.Excel.SetCellValue(b.SheetName, fmt.Sprintf("H%d", mergeEndRow), supplierName)
  236. }
  237. endRow := b.Row - 1
  238. // 组件名字
  239. startACell := fmt.Sprintf("%s%d", "B", startRow)
  240. endACell := fmt.Sprintf("%s%d", "B", endRow)
  241. b.Excel.MergeCell(b.SheetName, startACell, endACell)
  242. err := b.Excel.SetCellStyle(b.SheetName, startACell, endACell, b.AlignCenterStyle)
  243. if err != nil {
  244. return err
  245. }
  246. b.Excel.SetCellValue(b.SheetName, startACell, comp.Name)
  247. }
  248. // 预算
  249. planBudgetPrice += perBudgetPrice
  250. // 实际金额
  251. planRealPrice += perRealPrice
  252. }
  253. }
  254. totalBudgetPrice += planBudgetPrice
  255. totalRealPrice += planRealPrice
  256. // plan
  257. // b.row +2 分割每个计划
  258. planEndRow := b.Row
  259. planStartACell := fmt.Sprintf("%s%d", "A", planStartRow)
  260. planEndACell := fmt.Sprintf("%s%d", "A", planEndRow-1)
  261. b.Excel.MergeCell(b.SheetName, planStartACell, planEndACell)
  262. err := b.Excel.SetCellStyle(b.SheetName, planStartACell, planEndACell, b.AlignCenterStyle)
  263. if err != nil {
  264. return err
  265. }
  266. b.Excel.SetCellValue(b.SheetName, planStartACell, plan.Name)
  267. // b.Row += 2
  268. }
  269. // summaryEndRow := b.Row
  270. // startACell := fmt.Sprintf("%s%d", "A", summaryEndRow)
  271. // endNell := fmt.Sprintf("%s%d", "N", summaryEndRow)
  272. // OCell := fmt.Sprintf("%s%d", "O", summaryEndRow)
  273. // PCell := fmt.Sprintf("%s%d", "P", summaryEndRow)
  274. // b.Excel.MergeCell(b.SheetName, startACell, endNell)
  275. // b.Excel.SetCellStyle(b.SheetName, startACell, endNell, b.AlignCenterStyle)
  276. // b.Excel.SetCellValue(b.SheetName, startACell, "生产计划汇总金额")
  277. // // 生产预算汇总
  278. // b.Excel.SetCellStyle(b.SheetName, OCell, OCell, b.AlignCenterStyle)
  279. // totalOrderRealPrice := fmt.Sprintf("%.3f", totalBudgetPrice)
  280. // b.FormatToEmpty(&totalOrderRealPrice)
  281. // b.Excel.SetCellValue(b.SheetName, OCell, totalOrderRealPrice)
  282. // // 生产实际汇总
  283. // b.Excel.SetCellStyle(b.SheetName, PCell, PCell, b.AlignCenterStyle)
  284. // totalRealPricef := fmt.Sprintf("%.3f", totalRealPrice)
  285. // b.FormatToEmpty(&totalRealPricef)
  286. // b.Excel.SetCellValue(b.SheetName, PCell, totalRealPricef)
  287. return nil
  288. }
  289. func (b *PlanSummaryExcel) drawSupplierContent() error {
  290. b.Row += 2
  291. supplier := ""
  292. // summaryPlans
  293. // 预算金额汇总
  294. var totalBudgetPrice float64 = 0.00
  295. // 实际金额汇总
  296. var totalRealPrice float64 = 0.00
  297. for _, splan := range b.Content.Plans {
  298. planStartRow := b.Row
  299. plan := splan.Plan
  300. comps := plan.Pack.Components
  301. // 预算金额汇总
  302. var planBudgetPrice float64 = 0.00
  303. // 实际金额汇总
  304. var planRealPrice float64 = 0.00
  305. if len(comps) > 0 {
  306. for _, comp := range comps {
  307. var perBudgetPrice float64 = 0.00
  308. var perRealPrice float64 = 0.00
  309. if len(comp.Stages) > 0 {
  310. startRow := 0
  311. cates := map[string][]int{}
  312. for _, stage := range comp.Stages {
  313. if stage.SupplierInfo != nil {
  314. if b.Content.SupplierId == stage.SupplierInfo.Id {
  315. supplier = stage.SupplierInfo.Name
  316. // 材料
  317. if startRow == 0 {
  318. startRow = b.Row
  319. }
  320. matHeigth := fmt.Sprintf("%d", stage.BatchSizeHeight)
  321. b.FormatToEmpty(&matHeigth)
  322. matWidth := fmt.Sprintf("%d", stage.BatchSizeWidth)
  323. b.FormatToEmpty(&matWidth)
  324. orderCount := fmt.Sprintf("%d", int(stage.OrderCount))
  325. b.FormatToEmpty(&orderCount)
  326. // 实际数量
  327. realCount := fmt.Sprintf("%d", stage.ConfirmCount)
  328. b.FormatToEmpty(&realCount)
  329. // 单价
  330. price := fmt.Sprintf("%.3f", stage.OrderPrice)
  331. b.FormatToEmpty(&price)
  332. // 预算金额
  333. budgetPrice := fmt.Sprintf("%.3f", stage.OrderPrice*float64(stage.OrderCount))
  334. perBudgetPrice += stage.OrderPrice * float64(stage.OrderCount)
  335. b.FormatToEmpty(&budgetPrice)
  336. // 实际金额
  337. perRealPrice += stage.OrderPrice * float64(stage.ConfirmCount)
  338. realPrice := fmt.Sprintf("%.3f", stage.OrderPrice*float64(stage.ConfirmCount))
  339. b.FormatToEmpty(&realPrice)
  340. unit := stage.Unit
  341. if stage.Unit == "吨" || stage.Unit == "平方米" {
  342. unit = "张"
  343. }
  344. supplierName := ""
  345. if stage.SupplierInfo != nil {
  346. supplierName = stage.SupplierInfo.Name
  347. }
  348. stageType := ""
  349. if stage.BillType > 0 {
  350. stage.Type = stage.BillType
  351. }
  352. if stage.Type == 1 {
  353. stageType = "材料采购"
  354. }
  355. if stage.Type == 2 {
  356. stageType = "工艺"
  357. }
  358. if stage.Type == 3 {
  359. stageType = "成品采购"
  360. }
  361. // 状态
  362. stop := false
  363. stageStatus := ""
  364. if len(stage.BillId) < 1 {
  365. stageStatus = "未生成订单"
  366. stop = true
  367. }
  368. // 审核状态
  369. if !stop {
  370. if splan.Reviewed[stage.BillId] == 1 {
  371. stageStatus = "已审核"
  372. } else {
  373. stageStatus = "未审核"
  374. stop = true
  375. }
  376. }
  377. // 接单状态
  378. if !stop {
  379. if splan.IsAck[stage.BillId] {
  380. stageStatus = "已接单"
  381. } else {
  382. stageStatus = "未接单"
  383. stop = true
  384. }
  385. }
  386. // 完成状态
  387. if splan.State[stage.BillId] == "complete" {
  388. stageStatus = "已完成"
  389. } else if splan.State[stage.BillId] == "created" {
  390. stageStatus = "进行中"
  391. }
  392. b.drawRow(b.Row, "", "", stageType, stage.Name, orderCount, realCount, stageStatus, supplierName, fmt.Sprintf("%.3f元/%s", stage.Price, stage.Unit), stage.Norm, matHeigth, matWidth, unit, price, budgetPrice, realPrice)
  393. if stage.SupplierInfo != nil {
  394. cates[stage.SupplierInfo.Name] = append(cates[stage.SupplierInfo.Name], b.Row)
  395. }
  396. b.Row++
  397. }
  398. }
  399. }
  400. // 合并同一供应商名
  401. for supplierName, cate := range cates {
  402. mergeStartRow := cate[0]
  403. mergeEndRow := cate[len(cate)-1]
  404. b.Excel.MergeCell(b.SheetName, fmt.Sprintf("H%d", mergeStartRow), fmt.Sprintf("H%d", mergeEndRow))
  405. b.Excel.SetCellValue(b.SheetName, fmt.Sprintf("H%d", mergeEndRow), supplierName)
  406. }
  407. if startRow != 0 {
  408. endRow := b.Row - 1
  409. // 组件名字
  410. startACell := fmt.Sprintf("%s%d", "B", startRow)
  411. endACell := fmt.Sprintf("%s%d", "B", endRow)
  412. b.Excel.MergeCell(b.SheetName, startACell, endACell)
  413. err := b.Excel.SetCellStyle(b.SheetName, startACell, endACell, b.AlignCenterStyle)
  414. if err != nil {
  415. return err
  416. }
  417. b.Excel.SetCellValue(b.SheetName, startACell, comp.Name)
  418. }
  419. }
  420. // 预算
  421. totalBudgetPrice += perBudgetPrice
  422. // 预算
  423. totalRealPrice += perRealPrice
  424. }
  425. }
  426. totalBudgetPrice += planBudgetPrice
  427. totalRealPrice += planRealPrice
  428. // plan
  429. // b.row +2 分割每个计划
  430. planEndRow := b.Row
  431. planStartACell := fmt.Sprintf("%s%d", "A", planStartRow)
  432. planEndACell := fmt.Sprintf("%s%d", "A", planEndRow-1)
  433. b.Excel.MergeCell(b.SheetName, planStartACell, planEndACell)
  434. err := b.Excel.SetCellStyle(b.SheetName, planStartACell, planEndACell, b.AlignCenterStyle)
  435. if err != nil {
  436. return err
  437. }
  438. b.Excel.SetCellValue(b.SheetName, planStartACell, plan.Name)
  439. }
  440. // summaryEndRow := b.Row
  441. // startACell := fmt.Sprintf("%s%d", "A", summaryEndRow)
  442. // endNell := fmt.Sprintf("%s%d", "N", summaryEndRow)
  443. // OCell := fmt.Sprintf("%s%d", "O", summaryEndRow)
  444. // PCell := fmt.Sprintf("%s%d", "P", summaryEndRow)
  445. // b.Excel.MergeCell(b.SheetName, startACell, endNell)
  446. // b.Excel.SetCellStyle(b.SheetName, startACell, endNell, b.AlignCenterStyle)
  447. // b.Excel.SetCellValue(b.SheetName, startACell, fmt.Sprintf("【%s】生产计划汇总金额", supplier))
  448. // // 生产预算汇总
  449. // b.Excel.SetCellStyle(b.SheetName, OCell, OCell, b.AlignCenterStyle)
  450. // totalOrderRealPrice := fmt.Sprintf("%.3f", totalBudgetPrice)
  451. // b.FormatToEmpty(&totalOrderRealPrice)
  452. // b.Excel.SetCellValue(b.SheetName, OCell, totalOrderRealPrice)
  453. // // 生产实际汇总
  454. // b.Excel.SetCellStyle(b.SheetName, PCell, PCell, b.AlignCenterStyle)
  455. // totalRealPricef := fmt.Sprintf("%.3f", totalRealPrice)
  456. // b.FormatToEmpty(&totalRealPricef)
  457. // b.Excel.SetCellValue(b.SheetName, PCell, totalRealPricef)
  458. // 供应商名字标题
  459. style, err := b.Excel.NewStyle(&excelize.Style{
  460. Alignment: &excelize.Alignment{Horizontal: "center", Vertical: "center", WrapText: true},
  461. })
  462. if err != nil {
  463. return err
  464. }
  465. err = b.Excel.SetCellStyle(b.SheetName, "A1", "G1", style)
  466. if err != nil {
  467. return err
  468. }
  469. b.Excel.SetRowHeight(b.SheetName, 1, 32)
  470. b.Excel.SetCellValue(b.SheetName, "A1", fmt.Sprintf("【%s】-汇总表", supplier))
  471. return nil
  472. }
  473. func (b *PlanSummaryExcel) Draws() {
  474. b.drawTitle()
  475. b.drawTableTitle()
  476. if !b.Content.SupplierId.IsZero() {
  477. b.drawSupplierContent()
  478. } else {
  479. b.drawAllContent()
  480. }
  481. }
  482. func NewPlanSummaryExcel(f *excelize.File) *PlanSummaryExcel {
  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", WrapText: true},
  491. Border: border,
  492. Font: &excelize.Font{Size: 10},
  493. })
  494. b := &PlanSummaryExcel{
  495. Title: "生产成本表",
  496. SheetName: "Sheet1",
  497. Excel: f,
  498. AlignCenterStyle: styleLeft,
  499. }
  500. f.SetColWidth(b.SheetName, "A", "D", 16)
  501. f.SetColWidth(b.SheetName, "E", "G", 12)
  502. f.SetColWidth(b.SheetName, "H", "H", 25)
  503. f.SetColWidth(b.SheetName, "I", "L", 16)
  504. f.SetColWidth(b.SheetName, "M", "M", 10)
  505. f.SetColWidth(b.SheetName, "N", "P", 16)
  506. f.SetPageMargins(b.SheetName, excelize.PageMarginTop(0), excelize.PageMarginLeft(0), excelize.PageMarginRight(0))
  507. return b
  508. }
  509. func (b *PlanSummaryExcel) FormatToEmpty(str *string) {
  510. if *str == "0" || *str == "0.000" {
  511. *str = ""
  512. }
  513. }