When I use birt api to export excel, the excel's sheet name is default set to Sheet0. Is there a way to custom sheet name in birt API?
In the "Property Editor - Report" in the tab "General" you can enter a "Title".
This value will be taken to name the sheet when exporting to excel.
I had a report with two table and page break after the first one so each table made their own sheet. after selecting each table go to the script and in the "on create" script, code this:
this.name = "Sheet Name";
Can add Dynamic/Static Worksheet name.
Select Table, click in Script (onPrepare), use below line of code.
reportContext.getDesignHandle().setProperty("title", "Sheetname1");
Sheet name can also be passed through request parameter (workSheetName) using below line of code.
reportContext.getDesignHandle().setProperty("title", params["workSheetName"].value);
Related
I have a word template with two table, I want to use Aspose to show a table and hide another table in word template based on a variable in java code, how to achieve this?
You can easily achieve what you need using IF field in your MS Word template document.
https://support.microsoft.com/en-us/office/field-codes-if-field-9f79e82f-e53b-4ff5-9d2c-ae3b22b7eb5e
in the condition you can insert a merge field or a bookmark and then update the condition upon execution mail merge or setting bookmark value using Aspose.Words.
For example, see the screenshot of the template document and the code to execute mail merge using Aspose.Words.
Document doc = new Document("C:\\Temp\\in.docx");
doc.getMailMerge().execute(new String[] { "test" }, new String[] { "first" });
doc.save("C:\\Temp\\out.docx");
If the output format is supposed to be MS Word document, you can also call Document.unlinkFields() method before saving, in this case IF field will be removed from the document and only the result will be preserved.
In report I have crosstab and one subreport, both in Summary Band.
Problem is repeating of Crosstab column header in XLS report.
(Want to have only one column header)
I've tried some tricks, but nothing is good enough.
1) If uncheck Crosstab Properties - Repeat Column Header result is ok but than don't have headers in HTML and PDF, it is not ok.
2) If IS_IGNORE_PAGINATION = true only for XLS, it is OK but for some reason subreport is not printing! (this is the biggest problem,don't know why?)
3) Properties like this are not applicable on CROSSTAB
result.put("net.sf.jasperreports.export.xls.exclude.origin.band.1", "pageHeader");
result.put("net.sf.jasperreports.export.xls.exclude.origin.band.2", "pageFooter");
result.put("net.sf.jasperreports.export.xls.exclude.origin.band.3", "columnHeader");
result.put("net.sf.jasperreports.export.xls.exclude.origin.keep.first.band.1", "columnHeader");
result.put("net.sf.jasperreports.export.xls.exclude.origin.keep.first.band.2", "pageHeader");
4) I have tried to put main page report page height to some big number like 999999 but still subreport is not printing if IS_IGNORE_PAGINATION = true
Is there some property for crosstab that can be set from Java, depending on output format?
I will answer to my own question.
After many attempts, due to a lack of time, I made a new report for XLS output format.
(Now I have two nearly same report, one for PDF and HTML, and other for XLS output format)
In report I have unchecked Crosstab Properties - Repeat Column Header.
The downside of this is maintenance, but for now this is the only solution.
I am using JasperReports to generate reports in xls format. I am trying to auto adjust the column and row with following code.
print.getPropertiesMap().setProperty("net.sf.jasperreports.print.keep.full.text", "true");
print.getPropertiesMap().setProperty("net.sf.jasperreports.export.xls.auto.fit.row","true");
print.getPropertiesMap().setProperty("net.sf.jasperreports.export.xls.auto.fit.column","true");
I can't quite figure out why this is not working.
One more property you would need
"net.sf.jasperreports.export.xls.wrap.text" to "false"
and also set isStretchWithOverflow to false
I'm working on a system where the users need to be able to upload an excel file to the server, then the system needs to process the excel file to load data into the XMPie uProduce system.
I already have it working to load CSV files into the system. I can confirm that the excel files have been uploaded to the server successfully. However, when my program then tries to access the excel file in order to read the data, it gets this error:
The Microsoft Jet database engine could not find the object 'Sheet1'. Make sure the object exists and that you spell its name and the path name correctly.
I am setting the filter as:
select * from [Sheet1]
I have also tried it as:
select * from [filename.xls]
Neither have worked. Does anyone have any suggestions what the SQL filter should be for pulling data from a database?
Try this..
Writing an Excel query is as similar as writing a query in any other traditional data storage like SQL Server, Oracle, etc. However there are a few differences. First, you have to specify your sheet name instead of your table name. Next, you have to give starting and end cell references. Watch my following code carefully:
SELECT * FROM [users$A1:F500]
Here users is the spread sheet name.
When specifying Excel sheet names in an SQL query via ADO or similar, you have to put a $ symbol at the end of the sheet name. Try:
SELECT * FROM [Sheet1$]
More info here
we have a function in our java based web application where user can download an excel sheet template from the web application. Fill their data in this template and then upload the same excel sheet.
The system then reads this excel file and save this data in the database.
Below is snapshot of template file with some sample data in it.
What I want is when users download template file (template file usually just has the headers, so users know which data goes in which column), excel sheet should have drop downs for Division, Product, secondary product , Region and country. So that users do not enter any invalid values in those columns.
As well, products varies according to divisions and secondary product varies according to products. Its more like dependent drop downs.
Basically I will need to create the excel sheet using Apache POI in which users will chose values from the drop dowsn instead of typing it themselevs.
Even though we do have server side validation where we check if the values entered by users are valid or not.
The reason we wnat to do this is that e.g. some users might enter country as US, some as USA and some as United states.
The same thing goes for products etc. user may enter product as GFFX or GFFX Structuring or gffx etc.
Is it possible to do this in excel sheet using POI? If not what are the other possible solutions or wasy to make sure users know what they have to enter in each columns?
EDIT 1 :
I could created the drop downs but is it possible to created the dependent drop downs?
I was about to suggest AurA's solution but it looks like you'll have to build the validation list at run-time indeed.
You should have a look at the POI Quick Guide, it seems they have exactly what you need:
hssf.usermodel (binary .xls format)
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet("Data Validation");
CellRangeAddressList addressList = new CellRangeAddressList(0, 0, 0, 0);
DVConstraint dvConstraint = DVConstraint.createExplicitListConstraint(new String[]{"10", "20", "30"});
DataValidation dataValidation = new HSSFDataValidation(addressList, dvConstraint);
dataValidation.setSuppressDropDownArrow(false);
sheet.addValidationData(dataValidation);
xssf.usermodel (.xlsx format)
XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet("Data Validation");
XSSFDataValidationHelper dvHelper = new XSSFDataValidationHelper(sheet);
XSSFDataValidationConstraint dvConstraint = (XSSFDataValidationConstraint)
dvHelper.createExplicitListConstraint(new String[]{"11", "21", "31"});
CellRangeAddressList addressList = new CellRangeAddressList(0, 0, 0, 0);
XSSFDataValidation validation = (XSSFDataValidation)dvHelper.createValidation(
dvConstraint, addressList);
validation.setShowErrorBox(true);
sheet.addValidationData(validation);
You can get drop-down list (after clicking right mouse button) in case you've added (using POI) suggestions to the rows upper the first row that is visible to the user and should be filled (thus the rows beneath the header contain suggestions and are hgidden).
You won't get (AFAIK) category dependancy with POI or even pure excel (without VBA) drop-down list (that holds suggestions on the basis of values entered earlier).
What you can do, is to use POI to fill helper sheet with appropriate raw data and use VBA to dynamically generate drop-downs that would allow to pick a value from a list.