plan-cost-excel.go 18 KB

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