This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Other JSE/JEE APIs and the fly likes SVTableModel only for HSSF. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "SVTableModel only for HSSF." Watch "SVTableModel only for HSSF." New topic
Author

SVTableModel only for HSSF.

Samir Banerjee
Ranch Hand

Joined: Jun 21, 2010
Posts: 72
First of all I should tell that I do not have much experiance of POI.
I am trying to port our POI API from version 2.5.1 to 3.6.
So I have converted HSSFWorkbook to Workbook for both .xls and .xlsx and all others like HSSFSheet to Sheet and HSSFCell to Cell etc.
Now at one point our code uses :

So the problem is SVTableModel is for HSSF types only.I wanted to know for common HSSF and XSSF what should I use.
Thanks in advance.


--------------------------------
Hi friends just editing again as I am really stuck...Kindly help.Thanks.
Samir Banerjee
Ranch Hand

Joined: Jun 21, 2010
Posts: 72
Please help me out with this one.If the problem is not clear please tell me I can elaborate it.I am stuck.
Priya Vedan
Greenhorn

Joined: Aug 17, 2009
Posts: 11
Hi Ankit.
I am trying to upgrade POI 3.1 to 3.6 any suggestions or lessons learnt. Please do let me know if you have any idea of displaying a prompt box when user enters invalid data into the excel sheet.

Regards,
Vedan
Samir Banerjee
Ranch Hand

Joined: Jun 21, 2010
Posts: 72
Hi Priya,
Actually I am stuck in one case and does not have any solution.I have one dedicated post also for that. Our application is like we upload a excel file as a template. We have some variable that we call as codes. We put them in the excel file and upload the file in DB. Now when we parse through the excel file when we see this variable we take this values from DB using some logic and then put them in the excel file. Except this everything else in that excel file we do not touch and render them as they are. Now the problem we are facing is if suppose there is a formula in one cell like F2-F3, that used to be rendered automatically by excel file we never touched those formula and it was working fine for POI 2.5. Now for the later versions its not working and the excel file gives value error for this.

I don't know how your application uses POI ie are the data in excel dynamic or static.But what I observed is version 3.6 I found useful to render the Chinese characters and some image files that were not rendered properly in 2.5 they are rendered properly now.

Now the question that you asked.If that I had to do in my application I would send an error message in some request attribute if user enters invalid value and while loading the JSP page I would check the error message if exists just show an alert box.

If my understanding is clear then let me know if you want more information on my given solution.Else you can elaborate your question.
Good to see you are working on POI.Please let me know if you use formulas and facing some issue.Hope we can help each other.

Thanks and Regards,
Aniket

Priya Vedan
Greenhorn

Joined: Aug 17, 2009
Posts: 11
Thank You Aniket.

My problem is we are not using any jsp's. I have this requirement where I need change the format of the given data using java batch jobs. This is the small picture I have of my project. Excel templates are send to user, user fills them n send them back. read the data, process it re write the data into mentioned format(XML, text, pdf, etc.). All my functionalities were working fine if the users enter valid data. For time being I am validating the excel columns after reading the excel templates. Now we have an additional requirement where I need to restrict the user from entering the invalid data in excel templates. If invalid data is entered in the columns i need to show a pop up / prompt box and prevent the user saving the data.
As we do not use web services in our project I am stuck with this issue. I just tried DVConstraint data Format but of no use. I am still digging into the code as of now...

Vedan


Priya Vedan
Greenhorn

Joined: Aug 17, 2009
Posts: 11
Hi Aniket,

I think this might help. this is what we are using.



//declare the starting row number
int rownum = 2;
for (int i = 0; i < 10; i++)
{
Row row = sheet.createRow(rownum++);
for (int j = 0; j < titles.length; j++)
{
Cell cell = row.createCell(j);
if(j == 33)// if the column read is equal to the column where totals are displayed...
{
//the 34th cell contains sum e.g. SUM(C3:I3)

String ref = "C" +rownum+ ":I" + rownum;
cell.setCellFormula("SUM("+ref+")");
cell.setCellStyle(styles.get("formula"));
}else {
cell.setCellStyle(styles.get("formula"));

}
}
}
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: SVTableModel only for HSSF.