├── .gitattributes
├── .github
├── dependabot.yml
└── workflows
│ ├── checkBuild.yml
│ ├── release.yml
│ ├── test-deploy.yml
│ └── update-from-template.yml
├── .gitignore
├── .idea
├── checkstyle-idea.xml
├── codeStyles
│ ├── Project.xml
│ └── codeStyleConfig.xml
├── inspectionProfiles
│ └── Project_Default.xml
└── saveactions_settings.xml
├── CHANGELOG.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── SECURITY.md
├── config
└── checkstyle
│ └── checkstyle.xml
├── pom.xml
└── src
└── main
├── java
└── xdev
│ ├── BISuite.java
│ ├── reports
│ └── jasper
│ │ ├── AbstractReportStub.java
│ │ ├── AbstractVirtualTableDataSource.java
│ │ ├── FieldMappingKey.java
│ │ ├── JRDataSourceMapper.java
│ │ ├── JRDataSourceMappingContainer.java
│ │ ├── JRJTableRendererDataSource.java
│ │ ├── JRMappedField.java
│ │ ├── JRRewindableDataSourceMapper.java
│ │ ├── JRVirtualTableDataSource.java
│ │ ├── JRVirtualTableFormattedDataSource.java
│ │ ├── JasperReportUtils.java
│ │ ├── Parameter.java
│ │ ├── Report.java
│ │ ├── ReportBuilder.java
│ │ ├── ReportException.java
│ │ ├── ReportStub.java
│ │ └── cmd
│ │ └── ReportCreation.java
│ └── tableexport
│ ├── Export.java
│ ├── JRVirtualTableDataSource.java
│ ├── cmd
│ ├── DataType.java
│ ├── ExportCreation.java
│ └── TableExportDebugger.java
│ ├── config
│ ├── AbstractColumn.java
│ ├── Column.java
│ ├── ColumnAlignment.java
│ ├── ColumnBorder.java
│ ├── ColumnPadding.java
│ ├── ColumnStyle.java
│ ├── ContentColumn.java
│ ├── DefaultColumnStyle.java
│ ├── DefaultPageProperties.java
│ ├── EmptyColumnBorder.java
│ ├── HeaderColumn.java
│ ├── LineStyle.java
│ ├── PageProperties.java
│ ├── TemplateColumn.java
│ ├── TemplateConfig.java
│ └── builder
│ │ ├── DefaultJTableConfigBuilder.java
│ │ ├── ExportConfigBuilder.java
│ │ ├── JTableViewConfigBuilder.java
│ │ ├── VTConfigBuilder.java
│ │ └── XdevTableConfigBuilder.java
│ ├── datasource
│ ├── DefaultBooleanToStringConverter.java
│ ├── ValueConverter.java
│ ├── XdevJTableRendererDataSource.java
│ └── XdevTableDataSource.java
│ ├── export
│ ├── ExportException.java
│ ├── ReportBuilder.java
│ ├── ReportExporter.java
│ └── writer
│ │ ├── CSVToFileWriter.java
│ │ ├── CSVToOutputStreamWriter.java
│ │ ├── ExportWriter.java
│ │ ├── ExportWriterException.java
│ │ ├── HtmlToFileWriter.java
│ │ ├── HtmlToOutputStreamWriter.java
│ │ ├── PdfToFileWriter.java
│ │ ├── PdfToOutputStreamWriter.java
│ │ ├── PrintWriter.java
│ │ ├── ReportToPreviewWriter.java
│ │ ├── RtfToFileWriter.java
│ │ ├── RtfToOutputStreamWriter.java
│ │ ├── XMLToFileWriter.java
│ │ ├── XMLToOutputStreamWriter.java
│ │ ├── XlsToFileWriter.java
│ │ ├── XlsToOutputStreamWriter.java
│ │ ├── XlsxToFileWriter.java
│ │ └── XlsxToOutputStreamWriter.java
│ └── utils
│ ├── DataSourceResourceBundle.java
│ ├── ExportUtils.java
│ ├── NullPatternConverter.java
│ ├── PatternConverter.java
│ └── VirtualTableColumnPatternConverter.java
└── resources
└── xdev
├── lic
└── pj.properties
└── tableexport
└── utils
├── xdevdatasource.properties
└── xdevdatasource_en.properties
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: github-actions
4 | directory: "/"
5 | schedule:
6 | interval: daily
7 | # Run it at a specific time so that we don't get emails all day long
8 | time: "00:00"
9 | open-pull-requests-limit: 10
10 | ignore:
11 | - dependency-name: "*"
12 | # GitHub actions are using git tags (v1 = v1.2 = v1.2.3) which should be compatible until a major change is performed
13 | update-types:
14 | - "version-update:semver-minor"
15 | - "version-update:semver-patch"
16 | - package-ecosystem: maven
17 | directory: "/"
18 | schedule:
19 | interval: daily
20 | # Run it at a specific time so that we don't get emails all day long
21 | time: "00:00"
22 | open-pull-requests-limit: 10
23 |
--------------------------------------------------------------------------------
/.github/workflows/checkBuild.yml:
--------------------------------------------------------------------------------
1 | name: Check Build
2 |
3 | on:
4 | workflow_dispatch:
5 | push:
6 | branches: [ develop ]
7 | paths-ignore:
8 | - '**.md'
9 | pull_request:
10 | branches: [ develop ]
11 | paths-ignore:
12 | - '**.md'
13 |
14 | jobs:
15 | build:
16 | runs-on: ubuntu-latest
17 |
18 | strategy:
19 | matrix:
20 | java: [8, 11, 17, 21]
21 | java-package: [jdk]
22 | distribution: [temurin]
23 |
24 | steps:
25 | - uses: actions/checkout@v4
26 |
27 | - name: Set up JDK
28 | uses: actions/setup-java@v4
29 | with:
30 | distribution: ${{ matrix.distribution }}
31 | java-version: ${{ matrix.java }}
32 | java-package: ${{ matrix.java-package }}
33 | cache: 'maven'
34 |
35 | - name: Build with Maven
36 | run: mvn -B clean verify
37 |
38 | - name: Check for uncommited changes
39 | run: |
40 | if [[ "$(git status --porcelain)" != "" ]]; then
41 | echo ----------------------------------------
42 | echo git status
43 | echo ----------------------------------------
44 | git status
45 | echo ----------------------------------------
46 | echo git diff
47 | echo ----------------------------------------
48 | git diff
49 | echo ----------------------------------------
50 | echo Troubleshooting
51 | echo ----------------------------------------
52 | echo "::error::Unstaged changes detected. Locally try running: git clean -ffdx && mvn -B clean verify"
53 | exit 1
54 | fi
55 |
56 | - uses: actions/upload-artifact@v3
57 | with:
58 | name: jars-java-${{ matrix.java }}
59 | path: target/*.jar
60 | if-no-files-found: error
61 |
--------------------------------------------------------------------------------
/.github/workflows/test-deploy.yml:
--------------------------------------------------------------------------------
1 | name: Test Deployment CI
2 |
3 | on:
4 | workflow_dispatch:
5 |
6 | jobs:
7 | publish_central: # Publish the code to central
8 | runs-on: ubuntu-latest
9 | steps:
10 | - uses: actions/checkout@v4
11 |
12 | - name: Set up JDK OSSRH
13 | uses: actions/setup-java@v4
14 | with: # running setup-java again overwrites the settings.xml
15 | distribution: 'temurin'
16 | java-version: '8'
17 | server-id: ossrh
18 | server-username: MAVEN_CENTRAL_USERNAME
19 | server-password: MAVEN_CENTRAL_TOKEN
20 | gpg-passphrase: MAVEN_GPG_PASSPHRASE
21 | gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
22 |
23 | - name: Publish to OSSRH
24 | run: mvn -B deploy -Possrh
25 | env:
26 | MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
27 | MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }}
28 | MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
29 |
--------------------------------------------------------------------------------
/.github/workflows/update-from-template.yml:
--------------------------------------------------------------------------------
1 | name: Update from Template
2 |
3 | # This workflow keeps the repo up to date with changes from the template repo (REMOTE_URL)
4 | # It duplicates the REMOTE_BRANCH (into UPDATE_BRANCH) and tries to merge it into the
5 | # this repos default branch (which is checked out here)
6 | # Note that this requires a PAT (Personal Access Token) - at best from a servicing account
7 | # Also note that you should have at least once merged the template repo into the current repo manually
8 | # otherwise a "refusing to merge unrelated histories" error might occur.
9 |
10 | on:
11 | schedule:
12 | - cron: '55 2 * * 1'
13 | workflow_dispatch:
14 |
15 | env:
16 | UPDATE_BRANCH: update-from-template
17 | REMOTE_URL: https://github.com/xdev-software/xdev-swing-framework-template.git
18 | REMOTE_BRANCH: master
19 |
20 | permissions:
21 | contents: write
22 | pull-requests: write
23 |
24 | jobs:
25 | update:
26 | runs-on: ubuntu-latest
27 |
28 | steps:
29 | - uses: actions/checkout@v4
30 | with:
31 | # Required because otherwise there are always changes detected when executing diff/rev-list
32 | fetch-depth: 0
33 | # If no PAT is used the following error occurs on a push:
34 | # refusing to allow a GitHub App to create or update workflow `.github/workflows/xxx.yml` without `workflows` permission
35 | token: ${{ secrets.UPDATE_FROM_TEMPLATE_PAT }}
36 |
37 | - name: Init Git
38 | run: |
39 | git config --global user.email "actions@github.com"
40 | git config --global user.name "GitHub Actions"
41 |
42 | - name: Main workflow
43 | id: main
44 | run: |
45 | echo "Adding remote template-repo"
46 | git remote add template ${{ env.REMOTE_URL }}
47 |
48 | echo "Fetching remote template repo"
49 | git fetch template
50 |
51 | echo "Deleting local branch that will contain the updates - if present"
52 | git branch -D ${{ env.UPDATE_BRANCH }} || true
53 |
54 | echo "Checking if the remote template repo has new commits"
55 | git rev-list ..template/${{ env.REMOTE_BRANCH }}
56 |
57 | if [ $(git rev-list --count ..template/${{ env.REMOTE_BRANCH }}) -eq 0 ]; then
58 | echo "There are no commits new commits on the template repo"
59 |
60 | echo "Deleting origin branch that contains the updates - if present"
61 | git push -f origin --delete ${{ env.UPDATE_BRANCH }} || true
62 |
63 | echo "abort=1" >> $GITHUB_OUTPUT
64 | exit 0
65 | fi
66 |
67 | echo "Found new commits on the template repo"
68 |
69 | echo "Creating update branch"
70 | git branch ${{ env.UPDATE_BRANCH }} template/${{ env.REMOTE_BRANCH }}
71 | git branch --unset-upstream ${{ env.UPDATE_BRANCH }}
72 |
73 | echo "Pushing update branch"
74 | git push -f -u origin ${{ env.UPDATE_BRANCH }}
75 |
76 | echo "Getting current branch"
77 | current_branch=$(git branch --show-current)
78 | echo "Current branch is $current_branch"
79 | echo "current_branch=$current_branch" >> $GITHUB_OUTPUT
80 |
81 | echo "abort=0" >> $GITHUB_OUTPUT
82 |
83 | - name: pull-request
84 | if: steps.main.outputs.abort == 0
85 | env:
86 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
87 | run: |
88 | gh_pr_up() {
89 | gh pr create -H "${{ env.UPDATE_BRANCH }}" "$@" || (git checkout "${{ env.UPDATE_BRANCH }}" && gh pr edit "$@")
90 | }
91 | gh_pr_up -B "${{ steps.main.outputs.current_branch }}" \
92 | --title "Update from template" \
93 | --body "An automated PR to sync changes from the template into this repo"
94 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Maven
2 | target/
3 | pom.xml.tag
4 | pom.xml.releaseBackup
5 | pom.xml.versionsBackup
6 | pom.xml.next
7 | release.properties
8 | dependency-reduced-pom.xml
9 | buildNumber.properties
10 | .mvn/timing.properties
11 | # https://github.com/takari/maven-wrapper#usage-without-binary-jar
12 | .mvn/wrapper/maven-wrapper.jar
13 |
14 |
15 | # Compiled class file
16 | *.class
17 |
18 | # Log file
19 | *.log
20 |
21 | # BlueJ files
22 | *.ctxt
23 |
24 | # Mobile Tools for Java (J2ME)
25 | .mtj.tmp/
26 |
27 | # Package/Binary Files don't belong into a git repo
28 | *.jar
29 | *.war
30 | *.nar
31 | *.ear
32 | *.zip
33 | *.tar.gz
34 | *.rar
35 | *.dll
36 | *.exe
37 | *.bin
38 |
39 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
40 | hs_err_pid*
41 |
42 |
43 | # bin / compiled stuff
44 | target/
45 |
46 |
47 | # JRebel
48 | **/resources/rebel.xml
49 | **/resources/rebel-remote.xml
50 |
51 | # eclispe stuff for root
52 | /.settings/
53 | /.classpath
54 | /.project
55 |
56 |
57 | # eclispe stuff for modules
58 | /*/.metadata/
59 | /*/.apt_generated_tests/
60 | /*/.settings/
61 | /*/.classpath
62 | /*/.project
63 | /*/RemoteSystemsTempFiles/
64 |
65 | #custom
66 | .flattened-pom.xml
67 | .tern-project
68 |
69 | # == IntelliJ ==
70 | *.iml
71 | *.ipr
72 |
73 | # Some files are user/installation independent and are used for configuring the IDE
74 | # See also https://stackoverflow.com/a/35279076
75 |
76 | .idea/*
77 | !.idea/saveactions_settings.xml
78 | !.idea/checkstyle-idea.xml
79 |
80 | !.idea/inspectionProfiles/
81 | .idea/inspectionProfiles/*
82 | !.idea/inspectionProfiles/Project_Default.xml
83 |
84 | !.idea/codeStyles/
85 | .idea/codeStyles/*
86 | !.idea/codeStyles/codeStyleConfig.xml
87 | !.idea/codeStyles/Project.xml
88 |
--------------------------------------------------------------------------------
/.idea/checkstyle-idea.xml:
--------------------------------------------------------------------------------
1 |
2 |
Create an issue or send a pull request
12 | * **Send pull requests**
If you want to contribute code, check out the development instructions below.
13 | * However when contributing new features, please first discuss the change you wish to make via issue with the owners of this repository before making a change. Otherwise your work might be rejected and your effort was pointless.
14 |
15 | We also encourage you to read the [contribution instructions by GitHub](https://docs.github.com/en/get-started/quickstart/contributing-to-projects).
16 |
17 | ## Developing
18 |
19 | ### Software Requirements
20 | You should have the following things installed:
21 | * Git
22 | * Java 8, 11 or 17 - should be as unmodified as possible (Recommended: [Eclipse Adoptium](https://adoptium.net/temurin/releases/))
23 | * Maven
24 |
25 | ### Recommended setup
26 | * Install ``IntelliJ`` (Community Edition is sufficient)
27 | * Install the following plugins:
28 | * [Save Actions](https://plugins.jetbrains.com/plugin/22113) - Provides save actions, like running the formatter or adding ``final`` to fields
29 | * [SonarLint](https://plugins.jetbrains.com/plugin/7973-sonarlint) - CodeStyle/CodeAnalysis
30 | * [Checkstyle-IDEA](https://plugins.jetbrains.com/plugin/1065-checkstyle-idea) - CodeStyle/CodeAnalysis
31 | * Import the project
32 | * Ensure that everything is encoded in ``UTF-8``
33 | * Ensure that the JDK/Java-Version is correct
34 |
35 | ## Releasing [](https://github.com/xdev-software/biapi/actions/workflows/release.yml)
36 |
37 | Before releasing:
38 | * Consider doing a [test-deployment](https://github.com/xdev-software/biapi/actions/workflows/test-deploy.yml?query=branch%3Adevelop) before actually releasing.
39 | * Check the [changelog](CHANGELOG.md)
40 |
41 | If the ``develop`` is ready for release, create a pull request to the ``master``-Branch and merge the changes.
42 |
43 | When the release is finished do the following:
44 | * Merge the auto-generated PR (with the incremented version number) back into the ``develop``
45 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://mvnrepository.com/artifact/com.xdev-software/biapi)
2 | [](https://github.com/xdev-software/biapi/actions/workflows/checkBuild.yml?query=branch%3Adevelop)
3 | [](https://javadoc.io/doc/com.xdev-software/biapi)
4 | # XDEV BI Suite (BIAPI)
5 |
6 | Java Swing provides a significant set of controls for developing graphical user interfaces (GUI), for example, buttons, labels, tabs, all formular-controls, table, tree and techniques about windowing / scenes. Many standard applications can easily be created with that. If you need innovative business applications and want to delight your users, you obviously need more.
7 |
8 | The XDEV **B**usiness **I**nteligence Suite provides you ultimate power features, which extremely upgrades your application and makes it multiple times more capable and comfortable. Extend your solutions with features your users only dream about yet. Best of all - the integrations is amazingly easy!
9 |
10 | ## XDEV-IDE
11 | The [XDEV(-IDE)](https://xdev.software/en/products/swing-builder) is a visual Java development environment for fast and easy application development (RAD - Rapid Application Development). XDEV differs from other Java IDEs such as Eclipse or NetBeans, focusing on programming through a far-reaching RAD concept. The IDE's main components are a Swing GUI builder, the XDEV Application Framework and numerous drag-and-drop tools and wizards with which the functions of the framework can be integrated.
12 |
13 | The XDEV-IDE was license-free up to version 4 inclusive and is available for Windows, Linux and macOS. From version 5, the previously proprietary licensed additional modules are included in the IDE and the license of the entire product has been converted to a paid subscription model. The XDEV Application Framework, which represents the core of the RAD concept of XDEV and is part of every XDEV application, was released as open-source in 2008.
14 |
15 | ## Support
16 | If you need support as soon as possible and you can't wait for any pull request, feel free to use [our support](https://xdev.software/en/services/support).
17 |
18 | ## Contributing
19 | See the [contributing guide](./CONTRIBUTING.md) for detailed instructions on how to get started with our project.
20 |
21 | ## Dependencies and Licenses
22 | View the [license of the current project](LICENSE) or the [summary including all dependencies](https://xdev-software.github.io/biapi/dependencies/)
23 |
--------------------------------------------------------------------------------
/SECURITY.md:
--------------------------------------------------------------------------------
1 | # Security Policy
2 |
3 | ## Reporting a Vulnerability
4 |
5 | Please report a security vulnerability [on GitHub Security Advisories](https://github.com/xdev-software/biapi/security/advisories/new).
6 |
--------------------------------------------------------------------------------
/src/main/java/xdev/BISuite.java:
--------------------------------------------------------------------------------
1 | /*
2 | * XDEV BI Suite - XDEV BI Suite
3 | * Copyright © 2011 XDEV Software (https://xdev.software)
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU Lesser General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public License
16 | * along with this program. If not, see
A {@link Extension} implementation which initialize needed classes for BI Suite.
24 | * 25 | * @author XDEV Software 26 | * @deprecated Will no longer be maintained and removed in the future 27 | */ 28 | @Deprecated 29 | public class BISuite implements Extension 30 | { 31 | /** 32 | * Current version of the bi suite. 33 | */ 34 | public final static Version VERSION = new Version(6,0,0,0); 35 | 36 | /** 37 | * X-API version required for the current version of the bi suite. 38 | */ 39 | private final static Version REQUIRED_XAPI_VERSION = new Version(5,0,0,0); 40 | 41 | public BISuite() 42 | { 43 | 44 | } 45 | 46 | /** 47 | * {@inheritDoc} 48 | */ 49 | @Override 50 | public void init(final Map
36 | * The developer only needs to subclass this abstract class and define the
37 | * getFieldValue
method.
38 | *
jrField
in the current
101 | * row. Lookup is done by field name (column name).
102 | *
103 | * @param jrField
104 | * the {@link JRField} instance defining (by name) the column of
105 | * the {@link VirtualTable} whose value shall be retrieved.
106 | * @return the binary value in the wrapped {@link VirtualTable} instance
107 | * from current row, column jrField
108 | *
109 | * @throws DBException
110 | * if the column (specified by jrField.getName()
)
111 | * could not be found or accessed
112 | * @throws IOException
113 | * if the column (specified by jrField.getName()
)
114 | * could not be found or accessed
115 | */
116 | protected Object getBinaryFieldValue(@NotNull final JRField jrField) throws DBException,
117 | IOException
118 | {
119 | XdevBlob blob = (XdevBlob)this.virtualTable.getValueAt(this.currentRowIndex,
120 | jrField.getName());
121 | InputStream is;
122 | if(blob != null)
123 | {
124 | is = blob.getBinaryStream();
125 | }
126 | else
127 | {
128 | is = null;
129 | }
130 |
131 | return is;
132 | }
133 |
134 | }
135 |
--------------------------------------------------------------------------------
/src/main/java/xdev/reports/jasper/FieldMappingKey.java:
--------------------------------------------------------------------------------
1 | /*
2 | * XDEV BI Suite - XDEV BI Suite
3 | * Copyright © 2011 XDEV Software (https://xdev.software)
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU Lesser General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public License
16 | * along with this program. If not, see 39 | * Waring: Works only for columns which are rendered by a 40 | * {@link TableCellRenderer} extending {@link JLabel}. 41 | *
42 | * 43 | * This data source does not consider a {@link TableCellRenderer} extending 44 | * {@link javax.swing.JCheckBox}. Use the XdevJTableRendererDataSource instead. 45 | * 46 | * @author XDEV Software 47 | * 48 | */ 49 | public class JRJTableRendererDataSource implements JRRewindableDataSource 50 | { 51 | 52 | /** 53 | * The {@link JTable} instance to be wrapped. 54 | */ 55 | protected final JTable table; 56 | /** 57 | * The current row index. Initialized to -1 as first row is retrieved by the 58 | * first next() call. 59 | */ 60 | protected int currentRowIndex = -1; 61 | 62 | 63 | /** 64 | * Straight forward constructor to wrap a given (non-null) {@link JTable}. 65 | * 66 | * @param table 67 | * the {@link JTable} to wrap 68 | */ 69 | public JRJTableRendererDataSource(@NotNull final JTable table) 70 | { 71 | 72 | if(table == null) 73 | { 74 | throw new IllegalArgumentException("table must not be null"); 75 | } 76 | this.table = table; 77 | } 78 | 79 | 80 | /** 81 | * Retrieves the value for columnjrField
in the current row.
82 | * Lookup is done by field name (column name).
83 | *
84 | * @param jrField
85 | * the {@link JRField} instance defining (by name) the column of
86 | * the {@link JTable} whose value shall be retrieved.
87 | * @return the value returned from the {@link TableCellRenderer} instance of
88 | * current row and column jrField
89 | * @throws JRException
90 | * if the column (specified by jrField.getName()
)
91 | * could not be found or the value of the
92 | * {@link TableCellRenderer} could not be accessed
93 | */
94 | @Override
95 | public Object getFieldValue(JRField jrField) throws JRException
96 | {
97 | int rowIndex = this.currentRowIndex;
98 | int columnIndex = this.getColumnIndex(this.table,jrField.getName());
99 |
100 | return this.getRendererValue(this.table.getValueAt(rowIndex,columnIndex),rowIndex,
101 | columnIndex);
102 |
103 | }
104 |
105 |
106 | /**
107 | * Moves the internal row cursor to the next row.
108 | *
109 | * @return if the internal row cursor points to an existing row
110 | * @throws JRException
111 | * can never happen
112 | */
113 | @Override
114 | public boolean next() throws JRException
115 | {
116 | return ++this.currentRowIndex < this.table.getRowCount();
117 | }
118 |
119 |
120 | /**
121 | * {@inheritDoc}
122 | */
123 | @Override
124 | public void moveFirst() throws JRException
125 | {
126 | this.currentRowIndex = -1;
127 | }
128 |
129 |
130 | /**
131 | * Returns the index for the given columnName.
132 | *
133 | * @param table
134 | * {@link JTable}
135 | * @param columnName
136 | * Name of the column to get the index for.
137 | * @return the index for the given columnName.
138 | */
139 | protected int getColumnIndex(JTable table, String columnName)
140 | {
141 | return table.getColumnModel().getColumnIndex(columnName);
142 | }
143 |
144 |
145 | /**
146 | * Returns the name for the given {@link TableColumn}.
147 | *
148 | * @param column
149 | * {@link TableColumn} to get the name for
150 | * @return the name for the given {@link TableColumn}.
151 | */
152 | protected String getTableColumnName(final TableColumn column)
153 | {
154 | return String.valueOf(column.getHeaderValue());
155 | }
156 |
157 |
158 | /**
159 | * Returns the {@link TableCellRenderer} value for the described item.
160 | *
161 | * @param value
162 | * value to be processed by the renderer
163 | * @param row
164 | * rowIndex of the {@link TableCellRenderer} to use
165 | * @param col
166 | * columnIndex of the {@link TableCellRenderer} to use
167 | * @return the {@link TableCellRenderer} value for the described item.
168 | */
169 | protected String getRendererValue(final Object value, final int row, final int col)
170 | {
171 | Component cpn = this.table.getCellRenderer(row,col).getTableCellRendererComponent(
172 | this.table,value,false,false,row,col);
173 | if(cpn instanceof JLabel)
174 | {
175 | return ((JLabel)cpn).getText();
176 | }
177 |
178 | return "";
179 | }
180 |
181 | }
182 |
--------------------------------------------------------------------------------
/src/main/java/xdev/reports/jasper/JRMappedField.java:
--------------------------------------------------------------------------------
1 | /*
2 | * XDEV BI Suite - XDEV BI Suite
3 | * Copyright © 2011 XDEV Software (https://xdev.software)
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU Lesser General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public License
16 | * along with this program. If not, see 34 | * {@link JRVirtualTableDataSource} ignores the format settings of the 35 | * underlining {@link VirtualTable} and leaves the formating up to the report. 36 | *
37 | * 38 | *39 | * If you want to use the format settings of the {@link VirtualTable} in your 40 | * report see {@link JRVirtualTableFormattedDataSource}. 41 | *
42 | * 43 | * @see JRVirtualTableFormattedDataSource 44 | * 45 | * @author XDEV Software 46 | * 47 | */ 48 | public class JRVirtualTableDataSource extends AbstractVirtualTableDataSource 49 | { 50 | 51 | /** 52 | * Straight forward constructor to wrap a given (non-null) 53 | * {@link VirtualTable}. 54 | * 55 | * @param virtualTable 56 | * the {@link VirtualTable} to wrap 57 | */ 58 | public JRVirtualTableDataSource(@NotNull final VirtualTable virtualTable) 59 | { 60 | super(virtualTable); 61 | } 62 | 63 | 64 | /** 65 | * Retrieves the value for columnjrField
in the current row.
66 | * Lookup is done by field name (column name).
67 | *
68 | * @param jrField
69 | * the {@link JRField} instance defining (by name) the column of
70 | * the {@link VirtualTable} whose value shall be retrieved.
71 | * @return the value in the wrapped {@link VirtualTable} instance from
72 | * current row, column jrField
73 | * @throws JRException
74 | * if the column (specified by jrField.getName()
)
75 | * could not be found or accessed
76 | */
77 | @Override
78 | public Object getFieldValue(@NotNull final JRField jrField) throws JRException
79 | {
80 | try
81 | {
82 | VirtualTableColumn> column = this.virtualTable.getColumn(jrField.getName());
83 |
84 | switch(column.getType())
85 | {
86 | case BINARY:
87 | return this.getBinaryFieldValue(jrField);
88 |
89 | case LONGVARBINARY:
90 | return this.getBinaryFieldValue(jrField);
91 |
92 | case VARBINARY:
93 | return this.getBinaryFieldValue(jrField);
94 |
95 | case BLOB:
96 | return this.getBinaryFieldValue(jrField);
97 |
98 | case CLOB:
99 | return ((XdevClob)this.virtualTable.getValueAt(this.currentRowIndex,
100 | jrField.getName())).toJDBCClob();
101 |
102 | default:
103 | return this.virtualTable.getValueAt(this.currentRowIndex,jrField.getName());
104 | }
105 |
106 | }
107 | catch(Exception e)
108 | {
109 | throw new JRException("Unable to get value for field '" + jrField.getName(),e);
110 | }
111 | }
112 |
113 | }
114 |
--------------------------------------------------------------------------------
/src/main/java/xdev/reports/jasper/JRVirtualTableFormattedDataSource.java:
--------------------------------------------------------------------------------
1 | /*
2 | * XDEV BI Suite - XDEV BI Suite
3 | * Copyright © 2011 XDEV Software (https://xdev.software)
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU Lesser General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public License
16 | * along with this program. If not, see 35 | * {@link JRVirtualTableDataSource} uses the format settings of the underlining 36 | * {@link VirtualTable}. 37 | *
38 | * 39 | *40 | * If you don't want to use the format settings of the {@link VirtualTable} in 41 | * your report see {@link JRVirtualTableFormattedDataSource}. 42 | *
43 | * 44 | * 45 | * @author XDEV Software 46 | * 47 | */ 48 | public class JRVirtualTableFormattedDataSource extends AbstractVirtualTableDataSource 49 | { 50 | 51 | /** 52 | * Straight forward constructor to wrap a given (non-null) 53 | * {@link VirtualTable}. 54 | * 55 | * @param virtualTable 56 | * the {@link VirtualTable} to wrap 57 | */ 58 | public JRVirtualTableFormattedDataSource(@NotNull final VirtualTable virtualTable) 59 | { 60 | super(virtualTable); 61 | } 62 | 63 | 64 | /** 65 | * Retrieves the formatted value for columnjrField
in the
66 | * current row. Lookup is done by field name (column name).
67 | *
68 | * @param jrField
69 | * the {@link JRField} instance defining (by name) the column of
70 | * the {@link VirtualTableException} whose formatted value shall
71 | * be retrieved.
72 | * @return the formatted value in the wrapped {@link VirtualTable} instance
73 | * from current row, column jrField
74 | * @throws JRException
75 | * if the column (specified by jrField.getName()
)
76 | * could not be found or accessed
77 | */
78 | @Override
79 | public Object getFieldValue(@NotNull final JRField jrField) throws JRException
80 | {
81 | try
82 | {
83 | VirtualTableColumn> column = this.virtualTable.getColumn(jrField.getName());
84 |
85 | switch(column.getType())
86 | {
87 | case BINARY:
88 | return this.getBinaryFieldValue(jrField);
89 |
90 | case LONGVARBINARY:
91 | return this.getBinaryFieldValue(jrField);
92 |
93 | case VARBINARY:
94 | return this.getBinaryFieldValue(jrField);
95 |
96 | case BLOB:
97 | return this.getBinaryFieldValue(jrField);
98 |
99 | case CLOB:
100 | return ((XdevClob)this.virtualTable.getValueAt(this.currentRowIndex,
101 | jrField.getName())).toJDBCClob();
102 |
103 | default:
104 | return this.virtualTable.getFormattedValueAt(this.currentRowIndex,
105 | jrField.getName());
106 | }
107 |
108 | }
109 | catch(Exception e)
110 | {
111 | throw new JRException("Unable to get value for field '" + jrField.getName(),e);
112 | }
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/src/main/java/xdev/reports/jasper/JasperReportUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * XDEV BI Suite - XDEV BI Suite
3 | * Copyright © 2011 XDEV Software (https://xdev.software)
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU Lesser General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public License
16 | * along with this program. If not, see 36 | * {@link JRVirtualTableDataSource} ignores the format settings of the 37 | * underlining {@link VirtualTable} and leaves the formating up to the report. 38 | *
39 | * 40 | *41 | * If you want to use the format settings of the {@link VirtualTable} in your 42 | * report see {@link JRVirtualTableFormattedDataSource}. 43 | *
44 | * 45 | * @see JRVirtualTableFormattedDataSource 46 | * 47 | * @author XDEV Software 48 | * 49 | */ 50 | public class JRVirtualTableDataSource extends AbstractVirtualTableDataSource 51 | { 52 | 53 | /** 54 | * Straight forward constructor to wrap a given (non-null) 55 | * {@link VirtualTable}. 56 | * 57 | * @param virtualTable 58 | * the {@link VirtualTable} to wrap 59 | */ 60 | public JRVirtualTableDataSource(@NotNull final VirtualTable virtualTable) 61 | { 62 | super(virtualTable); 63 | } 64 | 65 | 66 | /** 67 | * Retrieves the value for columnjrField
in the current row.
68 | * Lookup is done by field name (column name).
69 | *
70 | * @param jrField
71 | * the {@link JRField} instance defining (by name) the column of
72 | * the {@link VirtualTable} whose value shall be retrieved.
73 | * @return the value in the wrapped {@link VirtualTable} instance from
74 | * current row, column jrField
75 | * @throws JRException
76 | * if the column (specified by jrField.getName()
)
77 | * could not be found or accessed
78 | */
79 | @Override
80 | public Object getFieldValue(@NotNull final JRField jrField) throws JRException
81 | {
82 | try
83 | {
84 | VirtualTableColumn> column = this.virtualTable.getColumn(jrField.getName());
85 |
86 | switch(column.getType())
87 | {
88 | case BINARY:
89 | return "BINARY";
90 |
91 | case LONGVARBINARY:
92 | return "LONGVARBINARY";
93 |
94 | case VARBINARY:
95 | return "VARBINARY";
96 |
97 | case BLOB:
98 | return "BLOB";
99 |
100 | case CLOB:
101 | final XdevClob xClob = ((XdevClob)this.virtualTable.getValueAt(this.currentRowIndex,jrField.getName()));
102 | return xClob == null ? null : xClob.toString();
103 |
104 | default:
105 | return this.virtualTable.getValueAt(this.currentRowIndex,jrField.getName());
106 | }
107 |
108 | }
109 | catch(Exception e)
110 | {
111 | throw new JRException("Unable to get value for field '" + jrField.getName(),e);
112 | }
113 | }
114 |
115 | }
116 |
--------------------------------------------------------------------------------
/src/main/java/xdev/tableexport/cmd/DataType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * XDEV BI Suite - XDEV BI Suite
3 | * Copyright © 2011 XDEV Software (https://xdev.software)
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU Lesser General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public License
16 | * along with this program. If not, see int
32 | */
33 | public int getPageHeight();
34 |
35 |
36 | /**
37 | * Return the spacing between columns.
38 | *
39 | * @return the spacing value between columns as int
40 | */
41 | public int getColumnSpacing();
42 |
43 |
44 | /**
45 | * Return the left margin. The working space is calculated by subtracting the margins from the page width.
46 | *
47 | * @return the left margin value as int
48 | */
49 | public int getLeftMargin();
50 |
51 |
52 | /**
53 | * Return the right margin. The working space is calculated by subtracting the margins from the page width.
54 | *
55 | * @return the right margin value as int
56 | */
57 | public int getRightMargin();
58 |
59 |
60 | /**
61 | * Return the top margin. The working space is calculated by subtracting the margins from the page height.
62 | *
63 | * @return the top margin value as int
64 | */
65 | public int getTopMargin();
66 |
67 |
68 | /**
69 | * Return the bottom margin. The working space is calculated by subtracting the margins from the page height.
70 | *
71 | * @return the bottom margin value as int
72 | */
73 | public int getBottomMargin();
74 |
75 | }
76 |
--------------------------------------------------------------------------------
/src/main/java/xdev/tableexport/config/TemplateColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * XDEV BI Suite - XDEV BI Suite
3 | * Copyright © 2011 XDEV Software (https://xdev.software)
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU Lesser General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public License
16 | * along with this program. If not, see
24 | * The class has general information like as width
,
25 | * name of the column
.
26 | *
NewColumn
44 | */
45 | public TemplateColumn()
46 | {
47 | this("NewColumn");
48 | }
49 |
50 | /**
51 | * Create a instance of this {@link TemplateColumn}.
52 | *
53 | * @param columnName
54 | */
55 | public TemplateColumn(final String columnName)
56 | {
57 | this.columnName = columnName;
58 | this.headerColumn = new HeaderColumn();
59 | this.contentColumn = new ContentColumn();
60 | }
61 |
62 |
63 | /**
64 | *
65 | * @param contentColumn
66 | */
67 | public void setContentColumn(ContentColumn contentColumn)
68 | {
69 | this.contentColumn = contentColumn;
70 | }
71 |
72 | public void setVisible(boolean visible)
73 | {
74 | this.visible = visible;
75 | }
76 |
77 | public void setHasHeaderColumn(boolean hasHeaderColumn)
78 | {
79 | this.hasHeaderColumn = hasHeaderColumn;
80 | }
81 |
82 |
83 | public void setHeaderColumn(HeaderColumn headerColumn)
84 | {
85 | this.headerColumn = headerColumn;
86 | }
87 |
88 |
89 | public void setWidth(int width)
90 | {
91 | this.width = width;
92 | }
93 |
94 |
95 | public void setColumnName(String columnName)
96 | {
97 | this.columnName = columnName;
98 | }
99 |
100 |
101 | public int getWidth()
102 | {
103 | return this.width;
104 | }
105 |
106 |
107 | public HeaderColumn getHeaderColumn()
108 | {
109 | return this.headerColumn;
110 | }
111 |
112 | public boolean isVisible()
113 | {
114 | return visible;
115 | }
116 |
117 | public ContentColumn getContentColumn()
118 | {
119 | return this.contentColumn;
120 | }
121 |
122 |
123 | public boolean hasHeaderColumn()
124 | {
125 | return this.hasHeaderColumn;
126 | }
127 |
128 |
129 | public String getColumnName()
130 | {
131 | return columnName;
132 | }
133 |
134 | }
135 |
--------------------------------------------------------------------------------
/src/main/java/xdev/tableexport/config/TemplateConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * XDEV BI Suite - XDEV BI Suite
3 | * Copyright © 2011 XDEV Software (https://xdev.software)
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU Lesser General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public License
16 | * along with this program. If not, see 194 | * Note - Excel allows sheet names up to 31 chars in length but other 195 | * applications allow more. Excel does not crash with names longer than 31 196 | * chars, but silently truncates such names to 31 chars. 197 | *
198 | * 199 | * @param name 200 | * the excel sheet name 201 | */ 202 | public void setSheetName(String name) 203 | { 204 | this.sheetName = name; 205 | } 206 | 207 | 208 | public void setBlankWhenNullValue(boolean blankWhenNullValue) 209 | { 210 | this.blankWhenNullValue = blankWhenNullValue; 211 | } 212 | 213 | 214 | // //////////////////////////////////////////// 215 | // /////GETTER 216 | // //////////////////////////////////////////// 217 | 218 | 219 | 220 | public PageProperties getPageProperties() 221 | { 222 | return this.pagePropertiesObj; 223 | } 224 | 225 | 226 | public String getSheetName() 227 | { 228 | return this.sheetName; 229 | } 230 | 231 | 232 | public boolean isBlankWhenNullValue() 233 | { 234 | return this.blankWhenNullValue; 235 | } 236 | 237 | } 238 | -------------------------------------------------------------------------------- /src/main/java/xdev/tableexport/config/builder/DefaultJTableConfigBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * XDEV BI Suite - XDEV BI Suite 3 | * Copyright © 2011 XDEV Software (https://xdev.software) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see31 | * Waring: The local's {@link Locale#GERMANY} and 32 | * {@link Locale#US} are supported. 33 | *
34 | * 35 | * @author XDEV Software (FHAE) 36 | * 37 | * @see DataSourceResourceBundle 38 | * 39 | */ 40 | public class DefaultBooleanToStringConverter implements ValueConverternull
a empty string is returned.
55 | *
56 | */
57 | @Override
58 | public String getValue(Boolean value)
59 | {
60 | if(value==null) return "";
61 | if(value)
62 | {
63 | return trueValue;
64 | }
65 | else
66 | {
67 | return falseValue;
68 | }
69 | }
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/src/main/java/xdev/tableexport/datasource/ValueConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * XDEV BI Suite - XDEV BI Suite
3 | * Copyright © 2011 XDEV Software (https://xdev.software)
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU Lesser General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public License
16 | * along with this program. If not, see 37 | * Waring: Works only for columns which are rendered by a 38 | * {@link TableCellRenderer} extending {@link JLabel} or {@link JCheckBox}. 39 | * If the {@link TableCellRenderer} extending a {@link JCheckBox} the {@link ValueConverter} is used to determine the {@link String} value. 40 | *
41 | * 42 | * @author XDEV Software(FHAE) 43 | * 44 | * @see ValueConverter 45 | * @see DefaultBooleanToStringConverter 46 | * 47 | */ 48 | public class XdevJTableRendererDataSource extends JRJTableRendererDataSource 49 | { 50 | private ValueConverter40 | * Specially column moving and sorting are supported. 41 | *
42 | * 43 | * 44 | * @author XDEV Software (FHAE) 45 | * 46 | * @param22 | * This is the base class for exception thrown if any error occurs while processing an export. 23 | *
24 | * @author XDEV Software(FHAE) 25 | */ 26 | public class ExportException extends Exception 27 | { 28 | 29 | /** 30 | * 31 | */ 32 | private static final long serialVersionUID = -3114768551530983515L; 33 | 34 | 35 | /** 36 | * Constructs an {@code ExportException} with the specified 37 | * detail message and nested exception. 38 | * 39 | * @param message the detail message 40 | * @param cause the nested exception 41 | */ 42 | public ExportException(String message, Throwable cause) 43 | { 44 | super(message,cause); 45 | } 46 | 47 | 48 | /** 49 | * Constructs an {@code ExportException} with the specified 50 | * detail message. 51 | * 52 | * @param message the detail message 53 | */ 54 | public ExportException(String message) 55 | { 56 | super(message); 57 | } 58 | 59 | 60 | /** 61 | * Constructs an {@code ExportException} with the specified 62 | * nested exception. 63 | * 64 | * @param cause the nested exception 65 | */ 66 | public ExportException(Throwable cause) 67 | { 68 | super(cause); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/xdev/tableexport/export/ReportExporter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * XDEV BI Suite - XDEV BI Suite 3 | * Copyright © 2011 XDEV Software (https://xdev.software) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see33 | * The generated CSV content is placed into a {@code File}. 34 | *
35 | * 36 | * @author XDEV Software(FHAE) 37 | */ 38 | @SuppressWarnings("deprecation") 39 | public class CSVToFileWriter implements ExportWriter 40 | { 41 | 42 | private final File file; 43 | 44 | 45 | /** 46 | * Constructs a {@link CSVToFileWriter} object given a {@link File} object. 47 | * 48 | * @param file a {@link File} object to write to. 49 | */ 50 | public CSVToFileWriter(final File file) 51 | { 52 | this.file = file; 53 | } 54 | 55 | /** 56 | * {@inheritDoc} 57 | */ 58 | @Override 59 | public void write(JasperPrint jasperPrint) throws ExportWriterException 60 | { 61 | final JRExporter exporter = new JRCsvExporter(); 62 | try 63 | { 64 | exporter.setParameter(JRExporterParameter.OUTPUT_FILE,this.file); 65 | exporter.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint); 66 | 67 | exporter.exportReport(); 68 | } 69 | catch(JRException e) 70 | { 71 | throw new ExportWriterException(e); 72 | } 73 | catch(Exception ie) 74 | { 75 | throw new ExportWriterException(ie); 76 | } 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/xdev/tableexport/export/writer/CSVToOutputStreamWriter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * XDEV BI Suite - XDEV BI Suite 3 | * Copyright © 2011 XDEV Software (https://xdev.software) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see33 | * The generated CSV content is placed into a {@code OutputStream}. 34 | *
35 | * 36 | * @author XDEV Software(FHAE) 37 | */ 38 | @SuppressWarnings("deprecation") 39 | public class CSVToOutputStreamWriter implements ExportWriter 40 | { 41 | private final OutputStream stream; 42 | 43 | 44 | /** 45 | * Constructs a {@link CSVToOutputStreamWriter} object given a 46 | * {@link OutputStream} object. 47 | * * 48 | * @param stream 49 | * a {@link OutputStream} object to write to. 50 | */ 51 | public CSVToOutputStreamWriter(final OutputStream stream) 52 | { 53 | this.stream = stream; 54 | } 55 | 56 | 57 | /** 58 | * {@inheritDoc} 59 | */ 60 | @Override 61 | public void write(JasperPrint jasperPrint) throws ExportWriterException 62 | { 63 | final JRExporter exporter = new JRCsvExporter(); 64 | try 65 | { 66 | exporter.setParameter(JRExporterParameter.OUTPUT_STREAM,this.stream); 67 | exporter.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint); 68 | 69 | exporter.exportReport(); 70 | } 71 | catch(JRException e) 72 | { 73 | throw new ExportWriterException(e); 74 | } 75 | catch(IllegalArgumentException ie) 76 | { 77 | throw new ExportWriterException(ie); 78 | } 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/xdev/tableexport/export/writer/ExportWriter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * XDEV BI Suite - XDEV BI Suite 3 | * Copyright © 2011 XDEV Software (https://xdev.software) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see31 | * The generated HTML content is placed into a {@code File}. 32 | *
33 | * 34 | * @author XDEV Software(FHAE) 35 | */ 36 | public class HtmlToFileWriter implements ExportWriter 37 | { 38 | private final File file; 39 | 40 | 41 | /** 42 | * Constructs a {@link HtmlToFileWriter} object given a {@link File} object. 43 | * 44 | * 45 | * @param file a {@link File} object to write to. 46 | */ 47 | public HtmlToFileWriter(final File file) 48 | { 49 | this.file = file; 50 | } 51 | 52 | 53 | /** 54 | * {@inheritDoc} 55 | */ 56 | @Override 57 | public void write(JasperPrint jasperPrint) throws ExportWriterException 58 | { 59 | try 60 | { 61 | JasperExportManager.exportReportToHtmlFile(jasperPrint,this.file.getAbsolutePath()); 62 | } 63 | catch(JRException e) 64 | { 65 | throw new ExportWriterException(e); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/xdev/tableexport/export/writer/HtmlToOutputStreamWriter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * XDEV BI Suite - XDEV BI Suite 3 | * Copyright © 2011 XDEV Software (https://xdev.software) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see32 | * The generated HTML content is placed into a {@code OutputStream}. 33 | *
34 | * 35 | * @author XDEV Software(FHAE) 36 | */ 37 | @SuppressWarnings("deprecation") 38 | public class HtmlToOutputStreamWriter implements ExportWriter 39 | { 40 | private final OutputStream outputStream; 41 | 42 | 43 | /** 44 | * Constructs a {@link HtmlToOutputStreamWriter} object given a 45 | * {@link OutputStream} object. 46 | * 47 | * 48 | * @param outputStream 49 | * a {@link OutputStream} object to write to. 50 | */ 51 | public HtmlToOutputStreamWriter(final OutputStream outputStream) 52 | { 53 | this.outputStream = outputStream; 54 | } 55 | 56 | 57 | /** 58 | * {@inheritDoc} 59 | */ 60 | @Override 61 | public void write(final JasperPrint jasperPrint) throws ExportWriterException 62 | { 63 | try 64 | { 65 | final HtmlExporter exporter = new HtmlExporter(); 66 | 67 | exporter.setParameter(JRExporterParameter.OUTPUT_STREAM,this.outputStream); 68 | exporter.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint); 69 | exporter.exportReport(); 70 | 71 | } 72 | catch(final JRException e) 73 | { 74 | throw new ExportWriterException(e); 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/xdev/tableexport/export/writer/PdfToFileWriter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * XDEV BI Suite - XDEV BI Suite 3 | * Copyright © 2011 XDEV Software (https://xdev.software) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see30 | * The generated PDF content is placed into a {@code File}. 31 | *
32 | * 33 | * @author XDEV Software(FHAE) 34 | */ 35 | public class PdfToFileWriter implements ExportWriter 36 | { 37 | private final File file; 38 | 39 | /** 40 | * Constructs a {@link PdfToFileWriter} object given a {@link File} object. 41 | * 42 | * 43 | * @param file a {@link File} object to write to. 44 | */ 45 | public PdfToFileWriter(final File file) 46 | { 47 | this.file = file; 48 | } 49 | 50 | /** 51 | * {@inheritDoc} 52 | */ 53 | @Override 54 | public void write(JasperPrint jasperPrint) 55 | throws ExportWriterException 56 | { 57 | try 58 | { 59 | JasperExportManager.exportReportToPdfFile(jasperPrint,this.file.getAbsolutePath()); 60 | } 61 | catch(JRException e) 62 | { 63 | throw new ExportWriterException(e); 64 | } 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/xdev/tableexport/export/writer/PdfToOutputStreamWriter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * XDEV BI Suite - XDEV BI Suite 3 | * Copyright © 2011 XDEV Software (https://xdev.software) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see31 | * The generated PDF content is placed into a {@code OutputStream}. 32 | *
33 | * 34 | * @author XDEV Software(FHAE) 35 | */ 36 | public class PdfToOutputStreamWriter implements ExportWriter 37 | { 38 | private final OutputStream outputstream; 39 | 40 | 41 | /** 42 | * Constructs a {@link PdfToOutputStreamWriter} object given a {@link OutputStream} object. 43 | * 44 | * 45 | * @param outputstream 46 | * a {@link OutputStream} object to write to. 47 | */ 48 | public PdfToOutputStreamWriter(final OutputStream outputstream) 49 | { 50 | this.outputstream = outputstream; 51 | } 52 | 53 | 54 | /** 55 | * {@inheritDoc} 56 | */ 57 | @Override 58 | public void write(JasperPrint jasperPrint) throws ExportWriterException 59 | { 60 | try 61 | { 62 | JasperExportManager.exportReportToPdfStream(jasperPrint,this.outputstream); 63 | } 64 | catch(JRException e) 65 | { 66 | throw new ExportWriterException(e); 67 | } 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/xdev/tableexport/export/writer/PrintWriter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * XDEV BI Suite - XDEV BI Suite 3 | * Copyright © 2011 XDEV Software (https://xdev.software) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see33 | * The generated RTF content is placed into a {@code File}. 34 | *
35 | * 36 | * @author XDEV Software(FHAE) 37 | */ 38 | @SuppressWarnings("deprecation") 39 | public class RtfToFileWriter implements ExportWriter 40 | { 41 | 42 | private final File file; 43 | 44 | 45 | /** 46 | * Constructs a {@link RtfToFileWriter} object given a {@link File} object. 47 | * 48 | * @param file a {@link File} object to write to. 49 | */ 50 | public RtfToFileWriter(final File file) 51 | { 52 | this.file = file; 53 | } 54 | 55 | /** 56 | * {@inheritDoc} 57 | */ 58 | @Override 59 | public void write(JasperPrint jasperPrint) throws ExportWriterException 60 | { 61 | final JRExporter exporter = new JRRtfExporter(); 62 | try 63 | { 64 | exporter.setParameter(JRExporterParameter.OUTPUT_FILE,this.file); 65 | exporter.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint); 66 | 67 | exporter.exportReport(); 68 | } 69 | catch(JRException e) 70 | { 71 | throw new ExportWriterException(e); 72 | } 73 | catch(Exception ie) 74 | { 75 | throw new ExportWriterException(ie); 76 | } 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/xdev/tableexport/export/writer/RtfToOutputStreamWriter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * XDEV BI Suite - XDEV BI Suite 3 | * Copyright © 2011 XDEV Software (https://xdev.software) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see33 | * The generated RTF content is placed into a {@code OutputStream}. 34 | *
35 | * 36 | * @author XDEV Software(FHAE) 37 | */ 38 | @SuppressWarnings("deprecation") 39 | public class RtfToOutputStreamWriter implements ExportWriter 40 | { 41 | private final OutputStream stream; 42 | 43 | 44 | /** 45 | * Constructs a {@link RtfToOutputStreamWriter} object given a 46 | * {@link OutputStream} object. 47 | * * 48 | * @param stream 49 | * a {@link OutputStream} object to write to. 50 | */ 51 | public RtfToOutputStreamWriter(final OutputStream stream) 52 | { 53 | this.stream = stream; 54 | } 55 | 56 | 57 | /** 58 | * {@inheritDoc} 59 | */ 60 | @Override 61 | public void write(JasperPrint jasperPrint) throws ExportWriterException 62 | { 63 | final JRExporter exporter = new JRRtfExporter(); 64 | try 65 | { 66 | exporter.setParameter(JRExporterParameter.OUTPUT_STREAM,this.stream); 67 | exporter.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint); 68 | 69 | exporter.exportReport(); 70 | } 71 | catch(JRException e) 72 | { 73 | throw new ExportWriterException(e); 74 | } 75 | catch(IllegalArgumentException ie) 76 | { 77 | throw new ExportWriterException(ie); 78 | } 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/xdev/tableexport/export/writer/XMLToFileWriter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * XDEV BI Suite - XDEV BI Suite 3 | * Copyright © 2011 XDEV Software (https://xdev.software) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see33 | * The generated XML content is placed into a {@code File}. 34 | *
35 | * 36 | * @author XDEV Software(FHAE) 37 | */ 38 | @SuppressWarnings("deprecation") 39 | public class XMLToFileWriter implements ExportWriter 40 | { 41 | 42 | private final File file; 43 | 44 | 45 | /** 46 | * Constructs a {@link XMLToFileWriter} object given a {@link File} object. 47 | * 48 | * @param file a {@link File} object to write to. 49 | */ 50 | public XMLToFileWriter(final File file) 51 | { 52 | this.file = file; 53 | } 54 | 55 | /** 56 | * {@inheritDoc} 57 | */ 58 | @Override 59 | public void write(JasperPrint jasperPrint) throws ExportWriterException 60 | { 61 | final JRExporter exporter = new JRXmlExporter(); 62 | try 63 | { 64 | exporter.setParameter(JRExporterParameter.OUTPUT_FILE,this.file); 65 | exporter.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint); 66 | 67 | exporter.exportReport(); 68 | } 69 | catch(JRException e) 70 | { 71 | throw new ExportWriterException(e); 72 | } 73 | catch(Exception ie) 74 | { 75 | throw new ExportWriterException(ie); 76 | } 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/xdev/tableexport/export/writer/XMLToOutputStreamWriter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * XDEV BI Suite - XDEV BI Suite 3 | * Copyright © 2011 XDEV Software (https://xdev.software) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see33 | * The generated XML content is placed into a {@code OutputStream}. 34 | *
35 | * 36 | * @author XDEV Software(FHAE) 37 | */ 38 | @SuppressWarnings("deprecation") 39 | public class XMLToOutputStreamWriter implements ExportWriter 40 | { 41 | private final OutputStream stream; 42 | 43 | 44 | /** 45 | * Constructs a {@link XMLToOutputStreamWriter} object given a 46 | * {@link OutputStream} object. 47 | * * 48 | * @param stream 49 | * a {@link OutputStream} object to write to. 50 | */ 51 | public XMLToOutputStreamWriter(final OutputStream stream) 52 | { 53 | this.stream = stream; 54 | } 55 | 56 | 57 | /** 58 | * {@inheritDoc} 59 | */ 60 | @Override 61 | public void write(JasperPrint jasperPrint) throws ExportWriterException 62 | { 63 | final JRExporter exporter = new JRXmlExporter(); 64 | try 65 | { 66 | exporter.setParameter(JRExporterParameter.OUTPUT_STREAM,this.stream); 67 | exporter.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint); 68 | 69 | exporter.exportReport(); 70 | } 71 | catch(JRException e) 72 | { 73 | throw new ExportWriterException(e); 74 | } 75 | catch(IllegalArgumentException ie) 76 | { 77 | throw new ExportWriterException(ie); 78 | } 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/xdev/tableexport/export/writer/XlsToFileWriter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * XDEV BI Suite - XDEV BI Suite 3 | * Copyright © 2011 XDEV Software (https://xdev.software) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see33 | * The generated XLS content is placed into a {@code File}. 34 | *
35 | * 36 | * @author XDEV Software(FHAE) 37 | */ 38 | public class XlsToFileWriter implements ExportWriter 39 | { 40 | private final File file; 41 | private final String sheetName; 42 | private final Boolean freezeHeadline; 43 | 44 | 45 | /** 46 | * Constructs a {@link XlsToFileWriter} object given a {@link File} object. 47 | * No freeze headline are created. 48 | * 49 | *50 | * Note - Excel allows sheet names up to 31 chars in length but other 51 | * applications allow more. Excel does not crash with names longer than 31 52 | * chars, but silently truncates such names to 31 chars. 53 | *
54 | * 55 | * @param file 56 | * a {@link File} object to write to. 57 | * @param sheetName 58 | * the excel sheet name 59 | */ 60 | public XlsToFileWriter(final File file, final String sheetName) 61 | { 62 | this(file,sheetName,false); 63 | } 64 | 65 | 66 | /** 67 | * Constructs a {@link XlsToFileWriter} object given a {@link File} object. 68 | * 69 | *70 | * Note - Excel allows sheet names up to 31 chars in length but other 71 | * applications allow more. Excel does not crash with names longer than 31 72 | * chars, but silently truncates such names to 31 chars. 73 | *
74 | * 75 | * @param file 76 | * a {@link File} object to write to. 77 | * @param freezeHeadline 78 | * iftrue
the freeze pane for the first row is
79 | * @param sheetName
80 | * the excel sheet name
81 | */
82 | public XlsToFileWriter(final File file, final String sheetName, final Boolean freezeHeadline)
83 | {
84 | this.file = file;
85 | this.sheetName = sheetName;
86 | this.freezeHeadline = freezeHeadline;
87 | }
88 |
89 |
90 | /**
91 | * {@inheritDoc}
92 | */
93 | @Override
94 | public void write(JasperPrint jasperPrint) throws ExportWriterException
95 | {
96 | final JRXlsExporter exporterXLS = new JRXlsExporter();
97 | try
98 | {
99 | ExportUtils.prepareExcelExporter(exporterXLS,jasperPrint,this.sheetName,
100 | this.freezeHeadline,this.file);
101 | exporterXLS.exportReport();
102 | }
103 | catch(JRException e)
104 | {
105 | throw new ExportWriterException(e);
106 | }
107 | catch(Exception ie)
108 | {
109 | throw new ExportWriterException(ie);
110 | }
111 | }
112 | }
113 |
--------------------------------------------------------------------------------
/src/main/java/xdev/tableexport/export/writer/XlsToOutputStreamWriter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * XDEV BI Suite - XDEV BI Suite
3 | * Copyright © 2011 XDEV Software (https://xdev.software)
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU Lesser General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public License
16 | * along with this program. If not, see 32 | * The generated XLS content is placed into a {@code OutputStream}. 33 | *
34 | * 35 | * @author XDEV Software(FHAE) 36 | */ 37 | public class XlsToOutputStreamWriter implements ExportWriter 38 | { 39 | 40 | private final OutputStream stream; 41 | private final String sheetName; 42 | private final Boolean freezeHeadline; 43 | 44 | /** 45 | * Constructs a {@link XlsToOutputStreamWriter} object given a {@link OutputStream} object. 46 | * No freeze headline are created. 47 | * 48 | *49 | * Note - Excel allows sheet names up to 31 chars in length but other applications allow more. 50 | * Excel does not crash with names longer than 31 chars, but silently truncates such names to 51 | * 31 chars. 52 | *
53 | * 54 | * @param stream a {@link OutputStream} object to write to. 55 | * @param sheetName the excel sheet name 56 | */ 57 | public XlsToOutputStreamWriter(final OutputStream stream, final String sheetName) 58 | { 59 | this(stream,sheetName,false); 60 | } 61 | 62 | /** 63 | * Constructs a {@link XlsToOutputStreamWriter} object given a {@link OutputStream} object. 64 | * 65 | *66 | * Note - Excel allows sheet names up to 31 chars in length but other applications allow more. 67 | * Excel does not crash with names longer than 31 chars, but silently truncates such names to 68 | * 31 chars. 69 | *
70 | * 71 | * @param stream a {@link OutputStream} object to write to. 72 | * @param freezeHeadline iftrue
the freeze pane for the first row is
73 | * created
74 | * @param sheetName the excel sheet name
75 | */
76 | public XlsToOutputStreamWriter(final OutputStream stream, final String sheetName, final Boolean freezeHeadline)
77 | {
78 | this.stream = stream;
79 | this.sheetName = sheetName;
80 | this.freezeHeadline = freezeHeadline;
81 | }
82 |
83 |
84 | /**
85 | * {@inheritDoc}
86 | */
87 | @Override
88 | public void write(JasperPrint jasperPrint) throws ExportWriterException
89 | {
90 | final JRXlsExporter exporterXLS = new JRXlsExporter();
91 | try
92 | {
93 | ExportUtils.prepareExcelExporter(exporterXLS,jasperPrint,this.sheetName,this.freezeHeadline,this.stream);
94 | exporterXLS.exportReport();
95 | }
96 | catch(JRException e)
97 | {
98 | throw new ExportWriterException(e);
99 | }
100 | catch(IllegalArgumentException ie)
101 | {
102 | throw new ExportWriterException(ie);
103 | }
104 | }
105 |
106 | }
107 |
--------------------------------------------------------------------------------
/src/main/java/xdev/tableexport/export/writer/XlsxToFileWriter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * XDEV BI Suite - XDEV BI Suite
3 | * Copyright © 2011 XDEV Software (https://xdev.software)
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU Lesser General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public License
16 | * along with this program. If not, see 33 | * The generated XLSX content is placed into a {@code File}. 34 | *
35 | * 36 | * @author XDEV Software(FHAE) 37 | */ 38 | public class XlsxToFileWriter implements ExportWriter 39 | { 40 | 41 | private final File file; 42 | private final String sheetName; 43 | private final Boolean freezeHeadline; 44 | 45 | 46 | /** 47 | * Constructs a {@link XlsxToFileWriter} object given a {@link File} object. 48 | * No freeze headline are created. 49 | * 50 | *51 | * Note - Excel allows sheet names up to 31 chars in length but other applications allow more. 52 | * Excel does not crash with names longer than 31 chars, but silently truncates such names to 53 | * 31 chars. 54 | *
55 | * 56 | * @param file a {@link File} object to write to. 57 | * @param sheetName the excel sheet name 58 | */ 59 | public XlsxToFileWriter(final File file, final String sheetName) 60 | { 61 | this(file,sheetName,false); 62 | } 63 | 64 | /** 65 | * Constructs a {@link XlsxToFileWriter} object given a {@link File} object. 66 | * 67 | *68 | * Note - Excel allows sheet names up to 31 chars in length but other applications allow more. 69 | * Excel does not crash with names longer than 31 chars, but silently truncates such names to 70 | * 31 chars. 71 | *
72 | * 73 | * @param file a {@link File} object to write to. 74 | * @param sheetName the excel sheet name 75 | * @param freezeHeadline iftrue
the freeze pane for the first row is
76 | */
77 | public XlsxToFileWriter(final File file, final String sheetName, final Boolean freezeHeadline)
78 | {
79 | this.file = file;
80 | this.sheetName = sheetName;
81 | this.freezeHeadline = freezeHeadline;
82 | }
83 |
84 |
85 | /**
86 | * {@inheritDoc}
87 | */
88 | @Override
89 | public void write(JasperPrint jasperPrint) throws ExportWriterException
90 | {
91 | final JRXlsxExporter exporterXLSX = new JRXlsxExporter();
92 | try
93 | {
94 | ExportUtils.prepareExcelExporter(exporterXLSX,jasperPrint,this.sheetName,this.freezeHeadline,this.file);
95 | exporterXLSX.exportReport();
96 | }
97 | catch(JRException e)
98 | {
99 | throw new ExportWriterException(e);
100 | }
101 | catch(Exception ie)
102 | {
103 | throw new ExportWriterException(ie);
104 | }
105 | }
106 |
107 | }
108 |
--------------------------------------------------------------------------------
/src/main/java/xdev/tableexport/export/writer/XlsxToOutputStreamWriter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * XDEV BI Suite - XDEV BI Suite
3 | * Copyright © 2011 XDEV Software (https://xdev.software)
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU Lesser General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public License
16 | * along with this program. If not, see 32 | * The generated XLSX content is placed into a {@code OutputStream}. 33 | *
34 | * 35 | * @author XDEV Software(FHAE) 36 | */ 37 | public class XlsxToOutputStreamWriter implements ExportWriter 38 | { 39 | private final OutputStream stream; 40 | private final String sheetName; 41 | private final Boolean freezeHeadline; 42 | 43 | 44 | /** 45 | * Constructs a {@link XlsxToOutputStreamWriter} object given a 46 | * {@link OutputStream} object. No freeze headline are created. 47 | *48 | * Note - Excel allows sheet names up to 31 chars in length but other 49 | * applications allow more. Excel does not crash with names longer than 31 50 | * chars, but silently truncates such names to 31 chars. 51 | *
52 | * 53 | * @param stream 54 | * a {@link OutputStream} object to write to. 55 | * @param sheetName 56 | * the excel sheet name 57 | */ 58 | public XlsxToOutputStreamWriter(final OutputStream stream, final String sheetName) 59 | { 60 | this(stream,sheetName,false); 61 | } 62 | 63 | 64 | /** 65 | * Constructs a {@link XlsxToOutputStreamWriter} object given a 66 | * {@link OutputStream} object. 67 | * 68 | *69 | * Note - Excel allows sheet names up to 31 chars in length but other 70 | * applications allow more. Excel does not crash with names longer than 31 71 | * chars, but silently truncates such names to 31 chars. 72 | *
73 | * 74 | * @param stream 75 | * a {@link OutputStream} object to write to. 76 | * @param sheetName 77 | * the excel sheet name 78 | * @param freezeHeadline 79 | * iftrue
the freeze pane for the first row is
80 | */
81 | public XlsxToOutputStreamWriter(final OutputStream stream, final String sheetName,
82 | final Boolean freezeHeadline)
83 | {
84 | this.stream = stream;
85 | this.sheetName = sheetName;
86 | this.freezeHeadline = freezeHeadline;
87 | }
88 |
89 |
90 | /**
91 | * {@inheritDoc}
92 | */
93 | @Override
94 | public void write(JasperPrint jasperPrint) throws ExportWriterException
95 | {
96 | final JRXlsxExporter exporterXLSX = new JRXlsxExporter();
97 | try
98 | {
99 | ExportUtils.prepareExcelExporter(exporterXLSX,jasperPrint,this.sheetName,
100 | this.freezeHeadline,this.stream);
101 | exporterXLSX.exportReport();
102 | }
103 | catch(JRException e)
104 | {
105 | throw new ExportWriterException(e);
106 | }
107 | catch(IllegalArgumentException ie)
108 | {
109 | throw new ExportWriterException(ie);
110 | }
111 | }
112 |
113 | }
114 |
--------------------------------------------------------------------------------
/src/main/java/xdev/tableexport/utils/DataSourceResourceBundle.java:
--------------------------------------------------------------------------------
1 | /*
2 | * XDEV BI Suite - XDEV BI Suite
3 | * Copyright © 2011 XDEV Software (https://xdev.software)
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU Lesser General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public License
16 | * along with this program. If not, see 33 | * The {@code ExportUtils} class provides utility methods for preparing the {@link JRAbstractExporter} 34 | *
35 | * 36 | * 37 | * @author XDEV Software(FHAE) 38 | */ 39 | @SuppressWarnings("deprecation") 40 | public class ExportUtils 41 | { 42 | 43 | /** 44 | * Prepare the {@code exporter} with all required {@link JRExporterParameter}. 45 | * 46 | * @param exporter 47 | * 48 | * @param jasperPrint An instance of the {@link JasperPrint} represents a report document that can be exported to other formats. 49 | * 50 | * @param sheetName An string representing custom sheet name 51 | * 52 | * @param stream the outputstream 53 | * 54 | * @throws IllegalArgumentException 55 | */ 56 | public static void prepareExcelExporter(final JRXlsAbstractExporter exporter, 57 | final JasperPrint jasperPrint, final String sheetName, final Boolean freezeHeadline, final OutputStream stream) 58 | throws IllegalArgumentException 59 | { 60 | initDefaultParameter(exporter,jasperPrint,sheetName,freezeHeadline); 61 | exporter.setParameter(JRExporterParameter.OUTPUT_STREAM,stream); 62 | } 63 | 64 | 65 | /** 66 | * Prepare the {@code exporter} with all required {@link JRExporterParameter}. 67 | * 68 | * @param exporter 69 | * 70 | * @param jasperPrint An instance of the {@link JasperPrint} represents a report document that can be exported to other formats. 71 | * 72 | * @param sheetName An string representing custom sheet name 73 | * 74 | * @param file the output file 75 | * 76 | * @throws IllegalArgumentException 77 | */ 78 | public static void prepareExcelExporter(final JRXlsAbstractExporter exporter, 79 | final JasperPrint jasperPrint, final String sheetName, final Boolean freezeHeadline, final File file) 80 | throws IllegalArgumentException 81 | { 82 | initDefaultParameter(exporter,jasperPrint,sheetName,freezeHeadline); 83 | exporter.setParameter(JRExporterParameter.OUTPUT_FILE,file); 84 | } 85 | 86 | private static void initDefaultParameter(final JRXlsAbstractExporter exporter, 87 | final JasperPrint jasperPrint, final String sheetName, final Boolean freezeHeadline) throws IllegalArgumentException 88 | { 89 | exporter.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint); 90 | exporter.setParameter(JRExporterParameter.IGNORE_PAGE_MARGINS,Boolean.FALSE); 91 | exporter.setParameter(JRXlsAbstractExporterParameter.IS_ONE_PAGE_PER_SHEET,Boolean.FALSE); 92 | exporter.setParameter(JRXlsAbstractExporterParameter.IS_WHITE_PAGE_BACKGROUND,Boolean.FALSE); 93 | 94 | exporter.setParameter(JRXlsAbstractExporterParameter.IS_DETECT_CELL_TYPE,Boolean.TRUE); 95 | exporter.setParameter(JRXlsAbstractExporterParameter.IS_IGNORE_CELL_BACKGROUND, 96 | Boolean.FALSE); 97 | exporter.setParameter(JRXlsAbstractExporterParameter.SHEET_NAMES,new String[]{sheetName}); 98 | 99 | 100 | 101 | exporter.setParameter(JRXlsAbstractExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, 102 | Boolean.TRUE); 103 | exporter.setParameter(JRXlsAbstractExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_COLUMNS, 104 | Boolean.TRUE); 105 | 106 | if(freezeHeadline) 107 | { 108 | final JRPropertiesUtil util = JRPropertiesUtil 109 | .getInstance(exporter.getJasperReportsContext()); 110 | util.setProperty(JRXlsAbstractExporter.PROPERTY_FREEZE_ROW_EDGE,"2"); 111 | } 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /src/main/java/xdev/tableexport/utils/NullPatternConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * XDEV BI Suite - XDEV BI Suite 3 | * Copyright © 2011 XDEV Software (https://xdev.software) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see