plan-summary-excel.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  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. stageStatus := ""
  196. if len(stage.BillId) < 1 {
  197. stageStatus = "未生成订单"
  198. }
  199. if splan.State[stage.BillId] == "created" {
  200. stageStatus = "进行中"
  201. }
  202. // 审核状态
  203. if splan.Reviewed[stage.BillId] == 1 {
  204. stageStatus = "已审核"
  205. } else {
  206. stageStatus = "未审核"
  207. }
  208. // 接单状态
  209. if splan.IsAck[stage.BillId] {
  210. stageStatus = "已接单"
  211. } else {
  212. stageStatus = "未接单"
  213. }
  214. // 完成状态
  215. if splan.State[stage.BillId] == "complete" {
  216. stageStatus = "已完成"
  217. }
  218. 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)
  219. if stage.SupplierInfo != nil {
  220. cates[stage.SupplierInfo.Name] = append(cates[stage.SupplierInfo.Name], b.Row)
  221. }
  222. b.Row++
  223. }
  224. for supplierName, cate := range cates {
  225. mergeStartRow := cate[0]
  226. mergeEndRow := cate[len(cate)-1]
  227. b.Excel.MergeCell(b.SheetName, fmt.Sprintf("H%d", mergeStartRow), fmt.Sprintf("H%d", mergeEndRow))
  228. b.Excel.SetCellValue(b.SheetName, fmt.Sprintf("H%d", mergeEndRow), supplierName)
  229. }
  230. endRow := b.Row - 1
  231. // 组件名字
  232. startACell := fmt.Sprintf("%s%d", "B", startRow)
  233. endACell := fmt.Sprintf("%s%d", "B", endRow)
  234. b.Excel.MergeCell(b.SheetName, startACell, endACell)
  235. err := b.Excel.SetCellStyle(b.SheetName, startACell, endACell, b.AlignCenterStyle)
  236. if err != nil {
  237. return err
  238. }
  239. b.Excel.SetCellValue(b.SheetName, startACell, comp.Name)
  240. }
  241. // 预算
  242. planBudgetPrice += perBudgetPrice
  243. // 实际金额
  244. planRealPrice += perRealPrice
  245. }
  246. }
  247. totalBudgetPrice += planBudgetPrice
  248. totalRealPrice += planRealPrice
  249. // plan
  250. planEndRow := b.Row
  251. planStartACell := fmt.Sprintf("%s%d", "A", planStartRow)
  252. planEndACell := fmt.Sprintf("%s%d", "A", planEndRow-1)
  253. b.Excel.MergeCell(b.SheetName, planStartACell, planEndACell)
  254. err := b.Excel.SetCellStyle(b.SheetName, planStartACell, planEndACell, b.AlignCenterStyle)
  255. if err != nil {
  256. return err
  257. }
  258. b.Excel.SetCellValue(b.SheetName, planStartACell, plan.Name)
  259. }
  260. // summaryEndRow := b.Row
  261. // startACell := fmt.Sprintf("%s%d", "A", summaryEndRow)
  262. // endNell := fmt.Sprintf("%s%d", "N", summaryEndRow)
  263. // OCell := fmt.Sprintf("%s%d", "O", summaryEndRow)
  264. // PCell := fmt.Sprintf("%s%d", "P", summaryEndRow)
  265. // b.Excel.MergeCell(b.SheetName, startACell, endNell)
  266. // b.Excel.SetCellStyle(b.SheetName, startACell, endNell, b.AlignCenterStyle)
  267. // b.Excel.SetCellValue(b.SheetName, startACell, "生产计划汇总金额")
  268. // // 生产预算汇总
  269. // b.Excel.SetCellStyle(b.SheetName, OCell, OCell, b.AlignCenterStyle)
  270. // totalOrderRealPrice := fmt.Sprintf("%.3f", totalBudgetPrice)
  271. // b.FormatToEmpty(&totalOrderRealPrice)
  272. // b.Excel.SetCellValue(b.SheetName, OCell, totalOrderRealPrice)
  273. // // 生产实际汇总
  274. // b.Excel.SetCellStyle(b.SheetName, PCell, PCell, b.AlignCenterStyle)
  275. // totalRealPricef := fmt.Sprintf("%.3f", totalRealPrice)
  276. // b.FormatToEmpty(&totalRealPricef)
  277. // b.Excel.SetCellValue(b.SheetName, PCell, totalRealPricef)
  278. return nil
  279. }
  280. func (b *PlanSummaryExcel) drawSupplierContent() error {
  281. b.Row += 2
  282. supplier := ""
  283. // summaryPlans
  284. // 预算金额汇总
  285. var totalBudgetPrice float64 = 0.00
  286. // 实际金额汇总
  287. var totalRealPrice float64 = 0.00
  288. for _, splan := range b.Content.Plans {
  289. planStartRow := b.Row
  290. plan := splan.Plan
  291. comps := plan.Pack.Components
  292. // 预算金额汇总
  293. var planBudgetPrice float64 = 0.00
  294. // 实际金额汇总
  295. var planRealPrice float64 = 0.00
  296. if len(comps) > 0 {
  297. for _, comp := range comps {
  298. var perBudgetPrice float64 = 0.00
  299. var perRealPrice float64 = 0.00
  300. if len(comp.Stages) > 0 {
  301. startRow := 0
  302. cates := map[string][]int{}
  303. for _, stage := range comp.Stages {
  304. if stage.SupplierInfo != nil {
  305. if b.Content.SupplierId == stage.SupplierInfo.Id {
  306. supplier = stage.SupplierInfo.Name
  307. // 材料
  308. if startRow == 0 {
  309. startRow = b.Row
  310. }
  311. matHeigth := fmt.Sprintf("%d", stage.BatchSizeHeight)
  312. b.FormatToEmpty(&matHeigth)
  313. matWidth := fmt.Sprintf("%d", stage.BatchSizeWidth)
  314. b.FormatToEmpty(&matWidth)
  315. orderCount := fmt.Sprintf("%d", int(stage.OrderCount))
  316. b.FormatToEmpty(&orderCount)
  317. // 实际数量
  318. realCount := fmt.Sprintf("%d", stage.ConfirmCount)
  319. b.FormatToEmpty(&realCount)
  320. // 单价
  321. price := fmt.Sprintf("%.3f", stage.OrderPrice)
  322. b.FormatToEmpty(&price)
  323. // 预算金额
  324. budgetPrice := fmt.Sprintf("%.3f", stage.OrderPrice*float64(stage.OrderCount))
  325. perBudgetPrice += stage.OrderPrice * float64(stage.OrderCount)
  326. b.FormatToEmpty(&budgetPrice)
  327. // 实际金额
  328. perRealPrice += stage.OrderPrice * float64(stage.ConfirmCount)
  329. realPrice := fmt.Sprintf("%.3f", stage.OrderPrice*float64(stage.ConfirmCount))
  330. b.FormatToEmpty(&realPrice)
  331. unit := stage.Unit
  332. if stage.Unit == "吨" || stage.Unit == "平方米" {
  333. unit = "张"
  334. }
  335. supplierName := ""
  336. if stage.SupplierInfo != nil {
  337. supplierName = stage.SupplierInfo.Name
  338. }
  339. stageType := ""
  340. if stage.BillType > 0 {
  341. stage.Type = stage.BillType
  342. }
  343. if stage.Type == 1 {
  344. stageType = "材料采购"
  345. }
  346. if stage.Type == 2 {
  347. stageType = "工艺"
  348. }
  349. if stage.Type == 3 {
  350. stageType = "成品采购"
  351. }
  352. // 状态
  353. stageStatus := ""
  354. if len(stage.BillId) < 1 {
  355. stageStatus = "未生成订单"
  356. }
  357. if splan.State[stage.BillId] == "created" {
  358. stageStatus = "进行中"
  359. }
  360. // 审核状态
  361. if splan.Reviewed[stage.BillId] == 1 {
  362. stageStatus = "已审核"
  363. } else {
  364. stageStatus = "未审核"
  365. }
  366. // 接单状态
  367. if splan.IsAck[stage.BillId] {
  368. stageStatus = "已接单"
  369. } else {
  370. stageStatus = "未接单"
  371. }
  372. // 完成状态
  373. if splan.State[stage.BillId] == "complete" {
  374. stageStatus = "已完成"
  375. }
  376. 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)
  377. if stage.SupplierInfo != nil {
  378. cates[stage.SupplierInfo.Name] = append(cates[stage.SupplierInfo.Name], b.Row)
  379. }
  380. b.Row++
  381. }
  382. }
  383. }
  384. // 合并同一供应商名
  385. for supplierName, cate := range cates {
  386. mergeStartRow := cate[0]
  387. mergeEndRow := cate[len(cate)-1]
  388. b.Excel.MergeCell(b.SheetName, fmt.Sprintf("H%d", mergeStartRow), fmt.Sprintf("H%d", mergeEndRow))
  389. b.Excel.SetCellValue(b.SheetName, fmt.Sprintf("H%d", mergeEndRow), supplierName)
  390. }
  391. if startRow != 0 {
  392. endRow := b.Row - 1
  393. // 组件名字
  394. startACell := fmt.Sprintf("%s%d", "B", startRow)
  395. endACell := fmt.Sprintf("%s%d", "B", endRow)
  396. b.Excel.MergeCell(b.SheetName, startACell, endACell)
  397. err := b.Excel.SetCellStyle(b.SheetName, startACell, endACell, b.AlignCenterStyle)
  398. if err != nil {
  399. return err
  400. }
  401. b.Excel.SetCellValue(b.SheetName, startACell, comp.Name)
  402. }
  403. }
  404. // 预算
  405. totalBudgetPrice += perBudgetPrice
  406. // 预算
  407. totalRealPrice += perRealPrice
  408. }
  409. }
  410. totalBudgetPrice += planBudgetPrice
  411. totalRealPrice += planRealPrice
  412. // plan
  413. // b.row +2 分割每个计划
  414. planEndRow := b.Row
  415. planStartACell := fmt.Sprintf("%s%d", "A", planStartRow)
  416. planEndACell := fmt.Sprintf("%s%d", "A", planEndRow-1)
  417. b.Excel.MergeCell(b.SheetName, planStartACell, planEndACell)
  418. err := b.Excel.SetCellStyle(b.SheetName, planStartACell, planEndACell, b.AlignCenterStyle)
  419. if err != nil {
  420. return err
  421. }
  422. b.Excel.SetCellValue(b.SheetName, planStartACell, plan.Name)
  423. }
  424. // summaryEndRow := b.Row
  425. // startACell := fmt.Sprintf("%s%d", "A", summaryEndRow)
  426. // endNell := fmt.Sprintf("%s%d", "N", summaryEndRow)
  427. // OCell := fmt.Sprintf("%s%d", "O", summaryEndRow)
  428. // PCell := fmt.Sprintf("%s%d", "P", summaryEndRow)
  429. // b.Excel.MergeCell(b.SheetName, startACell, endNell)
  430. // b.Excel.SetCellStyle(b.SheetName, startACell, endNell, b.AlignCenterStyle)
  431. // b.Excel.SetCellValue(b.SheetName, startACell, fmt.Sprintf("【%s】生产计划汇总金额", supplier))
  432. // // 生产预算汇总
  433. // b.Excel.SetCellStyle(b.SheetName, OCell, OCell, b.AlignCenterStyle)
  434. // totalOrderRealPrice := fmt.Sprintf("%.3f", totalBudgetPrice)
  435. // b.FormatToEmpty(&totalOrderRealPrice)
  436. // b.Excel.SetCellValue(b.SheetName, OCell, totalOrderRealPrice)
  437. // // 生产实际汇总
  438. // b.Excel.SetCellStyle(b.SheetName, PCell, PCell, b.AlignCenterStyle)
  439. // totalRealPricef := fmt.Sprintf("%.3f", totalRealPrice)
  440. // b.FormatToEmpty(&totalRealPricef)
  441. // b.Excel.SetCellValue(b.SheetName, PCell, totalRealPricef)
  442. // 供应商名字标题
  443. style, err := b.Excel.NewStyle(&excelize.Style{
  444. Alignment: &excelize.Alignment{Horizontal: "center", Vertical: "center", WrapText: true},
  445. })
  446. if err != nil {
  447. return err
  448. }
  449. err = b.Excel.SetCellStyle(b.SheetName, "A1", "G1", style)
  450. if err != nil {
  451. return err
  452. }
  453. b.Excel.SetRowHeight(b.SheetName, 1, 32)
  454. b.Excel.SetCellValue(b.SheetName, "A1", fmt.Sprintf("【%s】-汇总表", supplier))
  455. return nil
  456. }
  457. func (b *PlanSummaryExcel) Draws() {
  458. b.drawTitle()
  459. b.drawTableTitle()
  460. if !b.Content.SupplierId.IsZero() {
  461. b.drawSupplierContent()
  462. } else {
  463. b.drawAllContent()
  464. }
  465. }
  466. func NewPlanSummaryExcel(f *excelize.File) *PlanSummaryExcel {
  467. border := []excelize.Border{
  468. {Type: "top", Style: 1, Color: "000000"},
  469. {Type: "left", Style: 1, Color: "000000"},
  470. {Type: "right", Style: 1, Color: "000000"},
  471. {Type: "bottom", Style: 1, Color: "000000"},
  472. }
  473. styleLeft, _ := f.NewStyle(&excelize.Style{
  474. Alignment: &excelize.Alignment{Horizontal: "center", Vertical: "center", WrapText: true},
  475. Border: border,
  476. Font: &excelize.Font{Size: 10},
  477. })
  478. b := &PlanSummaryExcel{
  479. Title: "生产成本表",
  480. SheetName: "Sheet1",
  481. Excel: f,
  482. AlignCenterStyle: styleLeft,
  483. }
  484. f.SetColWidth(b.SheetName, "A", "D", 16)
  485. f.SetColWidth(b.SheetName, "E", "G", 12)
  486. f.SetColWidth(b.SheetName, "H", "H", 25)
  487. f.SetColWidth(b.SheetName, "I", "L", 16)
  488. f.SetColWidth(b.SheetName, "M", "M", 10)
  489. f.SetColWidth(b.SheetName, "N", "P", 16)
  490. f.SetPageMargins(b.SheetName, excelize.PageMarginTop(0), excelize.PageMarginLeft(0), excelize.PageMarginRight(0))
  491. return b
  492. }
  493. func (b *PlanSummaryExcel) FormatToEmpty(str *string) {
  494. if *str == "0" || *str == "0.000" {
  495. *str = ""
  496. }
  497. }