From 4b4d4df76b84974d16a5e39216dbc8fe9ccad832 Mon Sep 17 00:00:00 2001 From: Arpelicy <165371648+Arpelicy@users.noreply.github.com> Date: Sat, 4 Jan 2025 11:17:56 +0800 Subject: [PATCH] This closes #2061, fix border styles missing after saved workbook (#2064) - Using form template for GitHub issues - Typo fix for comments of the getSupportedLanguageInfo function --- .github/ISSUE_TEMPLATE/bug_report.md | 44 ------------ .github/ISSUE_TEMPLATE/bug_report.yml | 81 ++++++++++++++++++++++ .github/ISSUE_TEMPLATE/feature_request.md | 44 ------------ .github/ISSUE_TEMPLATE/feature_request.yml | 30 ++++++++ numfmt.go | 2 +- styles.go | 29 +++----- xmlStyles.go | 10 +-- 7 files changed, 127 insertions(+), 113 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/bug_report.yml delete mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.yml diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index a8c31a04b3..0000000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,44 +0,0 @@ ---- -name: Bug report -about: Create a report to help us improve - ---- - - - -**Description** - - - -**Steps to reproduce the issue:** -1. -2. -3. - -**Describe the results you received:** - -**Describe the results you expected:** - -**Output of `go version`:** - -```text -(paste your output here) -``` - -**Excelize version or commit ID:** - -```text -(paste here) -``` - -**Environment details (OS, Microsoft Excelâ„¢ version, physical, etc.):** diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000000..7005cd6c35 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,81 @@ +name: Bug report +description: Create a report to help us improve +body: + - type: markdown + attributes: + value: | + If you are reporting a new issue, make sure that we do not have any duplicates already open. You can ensure this by searching the issue list for this repository. If there is a duplicate, please close your issue and add a comment to the existing issue instead. + + - type: textarea + id: description + attributes: + label: Description + description: Briefly describe the problem you are having in a few paragraphs. + validations: + required: true + + - type: textarea + id: reproduction-steps + attributes: + label: Steps to reproduce the issue + description: Explain how to cause the issue in the provided reproduction. + placeholder: | + 1. + 2. + 3. + validations: + required: true + + - type: textarea + id: received + attributes: + label: Describe the results you received + validations: + required: true + + - type: textarea + id: expected + attributes: + label: Describe the results you expected + validations: + required: true + + - type: input + id: go-version + attributes: + label: Go version + description: | + Output of `go version`: + placeholder: e.g. 1.23.4 + validations: + required: true + + - type: input + id: excelize-version + attributes: + label: Excelize version or commit ID + description: | + Which version of Excelize are you using? + placeholder: e.g. 2.9.0 + validations: + required: true + + - type: textarea + id: env + attributes: + label: Environment + description: Environment details (OS, Microsoft Excel™ version, physical, etc.) + render: shell + validations: + required: true + + - type: checkboxes + id: checkboxes + attributes: + label: Validations + description: Before submitting the issue, please make sure you do the following + options: + - label: Check that there isn't already an issue that reports the same bug to avoid creating a duplicate. + required: true + - label: The provided reproduction is a minimal reproducible example of the bug. + required: true diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index 1737cd4421..0000000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,44 +0,0 @@ ---- -name: Feature request -about: Suggest an idea for this project - ---- - - - -**Description** - - - -**Steps to reproduce the issue:** -1. -2. -3. - -**Describe the results you received:** - -**Describe the results you expected:** - -**Output of `go version`:** - -```text -(paste your output here) -``` - -**Excelize version or commit ID:** - -```text -(paste here) -``` - -**Environment details (OS, Microsoft Excelâ„¢ version, physical, etc.):** diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 0000000000..af626b8e9a --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,30 @@ +name: Feature request +description: Suggest an idea for this project +body: + - type: markdown + attributes: + value: | + If you are reporting a new issue, make sure that we do not have any duplicates already open. You can ensure this by searching the issue list for this repository. If there is a duplicate, please close your issue and add a comment to the existing issue instead. + + - type: textarea + id: description + attributes: + label: Description + description: Describe the feature that you would like added + validations: + required: true + + - type: textarea + id: additional-context + attributes: + label: Additional context + description: Any other context or screenshots about the feature request here? + + - type: checkboxes + id: checkboxes + attributes: + label: Validations + description: Before submitting the issue, please make sure you do the following + options: + - label: Check that there isn't already an issue that requests the same feature to avoid creating a duplicate. + required: true diff --git a/numfmt.go b/numfmt.go index 97419a49c5..d8a9937626 100644 --- a/numfmt.go +++ b/numfmt.go @@ -4661,7 +4661,7 @@ var ( } ) -// getSupportedLanguageInfo returns language infomation by giving language code. +// getSupportedLanguageInfo returns language information by giving language code. // This function does not support different calendar type of the language // currently. For example: the hexadecimal language code 3010429 (fa-IR,301) // will be convert to 0429 (fa-IR). diff --git a/styles.go b/styles.go index 3cab1e8a59..d8b25886ae 100644 --- a/styles.go +++ b/styles.go @@ -1441,8 +1441,8 @@ func (f *File) getThemeColor(clr *xlsxColor) string { func (f *File) extractBorders(bdr *xlsxBorder, s *xlsxStyleSheet, style *Style) { if bdr != nil { var borders []Border - extractBorder := func(lineType string, line xlsxLine) { - if line.Style != "" { + extractBorder := func(lineType string, line *xlsxLine) { + if line != nil && line.Style != "" { borders = append(borders, Border{ Type: lineType, Color: f.getThemeColor(line.Color), @@ -1450,7 +1450,7 @@ func (f *File) extractBorders(bdr *xlsxBorder, s *xlsxStyleSheet, style *Style) }) } } - for i, line := range []xlsxLine{ + for i, line := range []*xlsxLine{ bdr.Left, bdr.Right, bdr.Top, bdr.Bottom, bdr.Diagonal, bdr.Diagonal, } { if i < 4 { @@ -2128,29 +2128,20 @@ func newBorders(style *Style) *xlsxBorder { var border xlsxBorder for _, v := range style.Border { if 0 <= v.Style && v.Style < 14 { - var color xlsxColor - color.RGB = getPaletteColor(v.Color) + line := &xlsxLine{Style: styleBorders[v.Style], Color: &xlsxColor{RGB: getPaletteColor(v.Color)}} switch v.Type { case "left": - border.Left.Style = styleBorders[v.Style] - border.Left.Color = &color + border.Left = line case "right": - border.Right.Style = styleBorders[v.Style] - border.Right.Color = &color + border.Right = line case "top": - border.Top.Style = styleBorders[v.Style] - border.Top.Color = &color + border.Top = line case "bottom": - border.Bottom.Style = styleBorders[v.Style] - border.Bottom.Color = &color + border.Bottom = line case "diagonalUp": - border.Diagonal.Style = styleBorders[v.Style] - border.Diagonal.Color = &color - border.DiagonalUp = true + border.Diagonal, border.DiagonalUp = line, true case "diagonalDown": - border.Diagonal.Style = styleBorders[v.Style] - border.Diagonal.Color = &color - border.DiagonalDown = true + border.Diagonal, border.DiagonalDown = line, true } } } diff --git a/xmlStyles.go b/xmlStyles.go index c23388abfe..edbc996f1f 100644 --- a/xmlStyles.go +++ b/xmlStyles.go @@ -162,11 +162,11 @@ type xlsxBorder struct { DiagonalDown bool `xml:"diagonalDown,attr,omitempty"` DiagonalUp bool `xml:"diagonalUp,attr,omitempty"` Outline bool `xml:"outline,attr,omitempty"` - Left xlsxLine `xml:"left"` - Right xlsxLine `xml:"right"` - Top xlsxLine `xml:"top"` - Bottom xlsxLine `xml:"bottom"` - Diagonal xlsxLine `xml:"diagonal"` + Left *xlsxLine `xml:"left"` + Right *xlsxLine `xml:"right"` + Top *xlsxLine `xml:"top"` + Bottom *xlsxLine `xml:"bottom"` + Diagonal *xlsxLine `xml:"diagonal"` Vertical *xlsxLine `xml:"vertical"` Horizontal *xlsxLine `xml:"horizontal"` }