Skip to content

Conversation

@wangwangxf
Copy link
Owner

@wangwangxf wangwangxf commented Jun 3, 2025

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

The description of the PR:

Other information:

Summary by Sourcery

Enhance Maven configuration, refactor project structure, and introduce an annotation-driven Excel-to-PDF conversion workflow with improved documentation and tests

New Features:

  • Add @CellVal annotation to map VO fields to Excel cells for template-driven data population
  • Introduce ExcelConvertPDF API to fill templates and convert one or multiple sheets to PDF
  • Integrate Alibaba easyexcel dependency for Excel operations

Enhancements:

  • Restructure code into util and excelModel packages and extract PDF table, image, color, and resource logic into dedicated classes
  • Upgrade Apache POI to 3.17 and refactor POIUtil for accurate color handling

Build:

  • Centralize POI version and packaging in pom.xml, add project metadata, licensing, SCM, developers, distribution management, and release profile

Documentation:

  • Expand README.md with detailed usage guide, example code, and project structure description

Tests:

  • Rewrite Excel2PDFTest to exercise the new annotation-based mapping and PDF conversion flow

caryyu and others added 10 commits January 5, 2018 18:11
錯誤修正(Bug fix)
1.Excel 的最後一行不會處理
2.若有 null cell(程式產生的 Excel),則排版換行會出錯

改進(Enhance)
1.可設定紙張大小,若單張 Excel,則依據版面設定中的紙張大小作為 PDF 輸出大小
2.允許設定是否自動產生頁碼
3.輸出欄位寬度與 Excel 同比例
4.納入Cell 內定義的格式(會計格式等)
5.表格置中(這個應該設計得更有彈性)
6.只要將測試Excel檔放入 src/test/resources 下,單元測試會自動納入,測試檔也放入 Git 以方便各類型 Excel 可加入測試
7.POI from 3.9 to 3.15
8.iText from 5.4.4 to 5.5.13
@sourcery-ai
Copy link

sourcery-ai bot commented Jun 3, 2025

Reviewer's Guide

This PR restructures the Maven build configuration with rich metadata and profiles, enriches the README with usage examples, modularizes the excel-to-PDF conversion logic into dedicated utility packages, and introduces an annotation-driven data model accompanied by an updated test harness.

Class Diagram for Data Model (LandTaxDeclarationVO) and Annotation (@CellVal)

classDiagram
  class LandTaxDeclarationVO {
    <<VO>>
    -String taxpayerID
    -String taxPeriod
    -String newDate
    -String accountCodeName
    -BigDecimal oneOneValue
    -BigDecimal oneTwoValue
    -String oneSixValue
    -BigDecimal oneSevenValue
    -BigDecimal oneNineValue
    -BigDecimal oneTenValue
    -BigDecimal oneElevenValue
    +String getTaxpayerID()
    +void setTaxpayerID(String)
    +String getTaxPeriod()
    +void setTaxPeriod(String)
    // ... (other getters and setters)
  }
  LandTaxDeclarationVO ..> CellVal : fields annotated by

  class CellVal {
    <<Annotation>>
    +int row()
    +int col()
  }
Loading

File-Level Changes

Change Details Files
Maven build configuration overhaul
  • Reorganized pom.xml to include project metadata (name, packaging, description, URL)
  • Introduced properties for Java and POI versions; replaced hard-coded versions with placeholders
  • Added licenses, SCM, developers, distributionManagement and Maven profiles
  • Updated dependencies (added easyexcel, upgraded POI to 3.17)
pom.xml
Enhanced project documentation
  • Expanded README.md with detailed instructions, code examples and images
  • Provided usage scenarios demonstrating annotation-driven filling and PDF output
README.md
Refactored and modularized excel-to-PDF utilities
  • Moved core conversion classes into com.github.caryyu.excel2pdf.uitil and excelModel packages
  • Rewrote POIUtil and POIImage for color and image extraction
  • Implemented PdfTableExcel, Excel2Pdf, ExcelConvertPDF, Resource, ExcelObject, Excel for modular processing
  • Cleaned up legacy classes and adjusted package paths
src/main/java/com/github/caryyu/excel2pdf/uitil/POIUtil.java
src/main/java/com/github/caryyu/excel2pdf/uitil/POIImage.java
src/main/java/com/github/caryyu/excel2pdf/uitil/PdfTool.java
src/main/java/com/github/caryyu/excel2pdf/uitil/PdfTableExcel.java
src/main/java/com/github/caryyu/excel2pdf/ExcelConvertPDF.java
src/main/java/com/github/caryyu/excel2pdf/uitil/Excel2Pdf.java
src/main/java/com/github/caryyu/excel2pdf/uitil/ExcelObject.java
src/main/java/com/github/caryyu/excel2pdf/uitil/Excel.java
src/main/java/com/github/caryyu/excel2pdf/uitil/Resource.java
Introduced annotation-driven Excel data model and updated test
  • Added @CellVal annotation to mark VO fields with row/column coordinates
  • Created LandTaxDeclarationVO with CellVal annotations for template binding
  • Updated Excel2PDFTest to use outPutWorkbookByModel and drive PDF conversion via annotations
src/main/java/com/github/caryyu/excel2pdf/annotation/CellVal.java
src/main/java/com/github/caryyu/excel2pdf/excelModel/LandTaxDeclarationVO.java
src/test/java/com/github/caryyu/excel2pdf/Excel2PDFTest.java

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants