• Post Reply Bookmark Topic Watch Topic
  • New Topic

Excel Data insert problem  RSS feed

 
Rakesh Keerthi
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Firstly, sorry for creating a duplicate post, since i was not sure of how to move topic from jsp to servlet.

And i'm trying to insert data into an excel sheet with the below Servlet.



But it is giving me the below Exception and stacktrace



i found that the problem is within the date field(please correct me if i'm wrong), if the problem is with the date, please let me know how i can fix it and also please let me know where am i going wrong.

Thanks
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apparently "2-Apr" is not of the format "d-mmm". Read the javadocs of the SimpleDateFormat class to learn what the letters of the format mean.
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rakesh Keerthi wrote:And i'm trying to insert data into an excel sheet with the below Servlet.

This is a genuine question, not a put-down, because I've seen a lot of posts like this now: Why do you need to do this?

It seems there are lots of apps around now that use Java to update Excel spreadsheets (and Word; and presumably other proprietary documents),
which seems to me to:
(a) Go against the ethos of the language, which is to be platform-independent.
(b) Be something that would probably be far easier done outside Java.

I suspect it has something to do with wanting to turn your spreadsheet into a database (or to get around MS's criminally awful "Office Automation"),
but I can't help feeling that it's not the best use of Java.

Please prove me wrong.

Winston
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see nothing strange in wanting to create XLS files in Java; it's a standard way of exporting data for human consumption. There isn't anything platform-specific about those files, given the universal availability of free office suites that can process them, and the fact that the format is publicly documented. The only thing strange about this particular approach is using ODBC; the Apache POI library would be the standard way to do this.
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:I see nothing strange in wanting to create XLS files in Java; it's a standard way of exporting data for human consumption.

It is? I thought it was a format for manipulating grid-like numeric data in pretty specialised ways - the purview of accountants not so long ago.

If all you need to do is disseminate it, read it in in CSV form (or whatever) and bash it out. Rakesh wants to update it, which IMO is a
completely different kettle of fish, and suggests to me that he wants to treat his spreadsheet (or, more likely, spreadsheets) like a database,
and use Java as an "auto-updater".

Have you read the standard? I've tried, and it's arcane to say the least (and I'm not quite sure why; it's just a grid of mutable cells isn't it?) - so
anyone that wants to start using Java to manipulate XLS's needs to understand that they're in for a big learning curve.

And I still reckon that there may be better alternatives out there that don't involve Java.

However, you may have to colour me 'old fart' on this one.

Winston
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thought it was a format for manipulating grid-like numeric data

This seems a bit like splitting hairs, but if we want to be that specific about it, then I'd say a file is a container for storing data. The manipulation is done by software, whether interactive like Excel, or automated like for example some Java process; it's separate from the issue of storage. (Not that I think this matters for the purposes of this discussion.)

I don't see where a big learning curve would come in - POI is pretty easy to use. Whether it's used for creating or updating files makes no big difference IMO. And XLS supports styles and all kinds of other formattings that CSV doesn't - which makes it much easier for humans to digest.

I would agree that it makes no sense to use XLS if no humans ever interact with the files.
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:I would agree that it makes no sense to use XLS if no humans ever interact with the files.

And this is maybe where I'm old hat, but to me, a spreadsheet was a format designed for a very specific purpose
and generally for individual interactive use.

Sure, you might e-mail the contents to someone so they could see the latest marketing forecast (or whatever);
or possibly even post the results on a website via the "Save as HTML" action, but updating them was normally the
responsibility of one person (or a small group).

What appears to be happening now is that swathes of them are updated in batch form using Java programs,
which seems to me to be using them like a database, when that was never what they were designed for.

Maybe what we need is some sort of "spreadsheet DB" (or QL) standard, but POI (or OpenOffice) seems an awfully
clunky way to go about it.

Winston
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!