Skip to content

Commit

Permalink
update example picture
Browse files Browse the repository at this point in the history
  • Loading branch information
tiechui1994 committed Mar 29, 2019
1 parent 44b2df7 commit 96d5b48
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
10 changes: 5 additions & 5 deletions cell.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,6 @@ func (cell *TextCell) GenerateAtomicCell(maxheight float64) error {
cell.pdf.Font(cell.font.Family, cell.font.Size, cell.font.Style)
cell.pdf.SetFontWithStyle(cell.font.Family, cell.font.Style, cell.font.Size)

// 背景颜色
if !util.IsEmpty(cell.backColor) {
cell.pdf.BackgroundColor(sx, sy, cell.width, maxheight, cell.backColor, "0000")
}

// 计算需要打印的行数
if maxheight > cell.height || math.Abs(maxheight-cell.height) < 0.01 {
lines = len(cell.contents)
Expand All @@ -196,6 +191,11 @@ func (cell *TextCell) GenerateAtomicCell(maxheight float64) error {
return nil
}

// 背景颜色
if !util.IsEmpty(cell.backColor) {
cell.pdf.BackgroundColor(sx, sy, cell.width, maxheight, cell.backColor, "0000")
}

// 写入cell数据
for i := 0; i < lines; i++ {
width := cell.pdf.MeasureTextWidth(cell.contents[i]) / cell.pdf.GetUnit()
Expand Down
Binary file modified example/pictures/table.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 7 additions & 3 deletions table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ func ComplexTableReportWithDataExecutor(report *core.Report) {
w := table.GetColWidth(i+2, j)
e := NewTextCell(w, lineHeight, lineSpace, report)
e.SetFont(f1)
e.SetBackColor("255,192,203")
if i%2 == 0 {
e.SetBackColor("255,192,203")
}
e.SetBorder(border)
e.SetContent(s)
cells[j].SetElement(e)
Expand Down Expand Up @@ -143,7 +145,9 @@ func ComplexTableReportExecutor(report *core.Report) {
// todo: div执行的严格顺序
e := NewTextCell(w, lineHeight, lineSpace, report)
e.SetFont(f1)
//e.SetBackColor("255,192,203")
if i%2 == 0 {
e.SetBackColor("255,192,203")
}
e.SetBorder(border)
e.SetContent(GetRandStr())
cells[j].SetElement(e)
Expand All @@ -158,7 +162,7 @@ func TestFormWithdata(t *testing.T) {
}

func TestForm(t *testing.T) {
//ComplexTableReport()
ComplexTableReport()
}

func GetRandStr() string {
Expand Down

0 comments on commit 96d5b48

Please sign in to comment.