An invoice generator with two independent interfaces: a Java command-line application for text and Excel invoices, and a React web application with PDF and Excel export.
| Interface | Stack | Output formats |
|---|---|---|
| Java CLI | Java 11, Maven, Apache POI | .txt and .xlsx |
Browser app in web-ui/ |
React 19, Vite 8, html2pdf.js, SheetJS xlsx |
.pdf and .xlsx |
The web application exports files in the browser and does not require the Java CLI to be running. PDF export uses html2pdf.js, not Apache PDFBox.
From the repository root, with a Node.js version supported by Vite 8 installed:
cd web-ui
npm install
npm run devOpen the URL printed by Vite. Enter company/customer information and line items, inspect the invoice preview, then choose Export PDF or Export Excel. For frontend scripts and implementation details, see the web application README.
The Java-specific features and instructions below describe the command-line interfaces.
- Interactive Console Input: Easy-to-use command-line interface for entering invoice data
- Multiple Output Formats: Generate invoices in text (.txt) and Excel (.xlsx) formats
- Professional Layout: Clean, professional invoice templates with proper formatting
- Sample Data: Generate sample invoices for demonstration purposes
- Flexible Configuration: Customizable tax rates, company information, and invoice notes
- Automatic Calculations: Automatic calculation of subtotals, taxes, and totals
- No-Maven Option: Run text-only version without installing Maven
- Runs with just Java installed
- Generates professional text-format invoices
- Perfect for quick testing and basic use
- Uses
InvoiceGeneratorTextAppclass
- Supports both text and Excel formats
- Requires Apache POI library for Excel generation
- Uses
InvoiceGeneratorAppclass - Professional Excel spreadsheets with formatting
- Java 11 or higher
- Maven 3.6 or higher
src/main/java/com/invoicegen/
├── InvoiceGeneratorApp.java # Main application class
├── model/
│ ├── Invoice.java # Invoice data model
│ ├── Customer.java # Customer data model
│ ├── Company.java # Company data model
│ └── InvoiceItem.java # Invoice item data model
├── generator/
│ ├── InvoiceGenerator.java # Generator interface
│ ├── TextInvoiceGenerator.java # Text format generator
│ └── ExcelInvoiceGenerator.java # Excel format generator
├── input/
│ └── ConsoleInputHandler.java # Console input handler
└── util/
└── SampleDataGenerator.java # Sample data utility
- Apache POI: For Excel file generation
- JUnit: For testing (development)
- Make sure you have Maven installed
- Navigate to the project directory
- Run the build command:
mvn clean compileFor immediate use without setting up Maven:
run-sample-simple.batrun-simple.batNote: These scripts generate text-format invoices only. For Excel support, use the Maven approach below.
mvn exec:java -Dexec.mainClass="com.invoicegen.InvoiceGeneratorApp"mvn exec:java -Dexec.mainClass="com.invoicegen.InvoiceGeneratorApp" -Dexec.args="--sample"mvn clean packagejava -jar target/invoice-generator-1.0-SNAPSHOT.jarjava -jar target/invoice-generator-1.0-SNAPSHOT.jar --samplerun-simple.bat- Text-only interactive mode (no Maven)run-sample-simple.bat- Text-only sample invoice (no Maven)run.bat- Full featured interactive mode (requires Maven)run-sample.bat- Full featured sample invoice (requires Maven)
When you run the application in interactive mode, you'll be prompted to enter:
-
Invoice Information:
- Invoice number
- Invoice date (or use today's date)
-
Company Information:
- Company name
- Address details
- Contact information
- Website and Tax ID (optional)
-
Customer Information:
- Customer name
- Address details
- Contact information
-
Invoice Items:
- Description
- Quantity
- Unit price
- (Add multiple items, press Enter with empty description to finish)
-
Additional Settings:
- Tax rate (default: 10%)
- Notes (optional)
-
Output Options:
- Choose format: Text, Excel, or Both
- Specify output directory
Running with --sample generates a pre-configured invoice with sample data, demonstrating all features of the application.
The application generates invoices with timestamps in the filename:
- Text Format:
invoice_[number]_[timestamp].txt - Excel Format:
invoice_[number]_[timestamp].xlsx - Sample Files:
sample_invoice_[timestamp].txt/xlsx
- Clean ASCII layout
- Properly aligned columns
- Professional header and footer
- Detailed item breakdown
- Tax calculations
- Professional spreadsheet layout
- Formatted cells with borders
- Currency formatting
- Styled headers
- Proper column sizing
Both formats include:
- Company letterhead information
- Customer billing details
- Itemized list of products/services
- Subtotal calculations
- Tax calculations
- Final total
- Payment terms
- Optional notes
You can easily customize:
- Tax Rates: Modify the default tax rate or enter custom rates
- Invoice Templates: Edit the generator classes to change layout
- Company Defaults: Modify
SampleDataGenerator.javafor default company info - Output Formats: Extend
InvoiceGeneratorinterface for new formats
The application includes robust error handling for:
- Invalid date formats
- Invalid numeric inputs
- File I/O operations
- Missing directories (automatically created)
- New Output Formats: Implement the
InvoiceGeneratorinterface - New Input Methods: Create classes similar to
ConsoleInputHandler - Additional Fields: Extend the model classes as needed
Run the test suite:
mvn testThis project is open source and available under the MIT License.
For issues or questions, please refer to the source code documentation or create an issue in the project repository.