Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-11-2008, 03:20 PM
Member
 
Join Date: Mar 2008
Posts: 1
yuvaraj23 is on a distinguished road
Regarding retrieval of sheet names from a excel workbook
Hi all,

I want to retrive all the sheets in a excel workbook. the following is the code i was written and this gives the table name along with some other values.


Connection con;
Statement st;
ResultSet rs,ps;
ResultSetMetaData rsmd;
DatabaseMetaData dbmd;

public void Connect_Excel(String WorkBookName,String list[])
{
con = null;
String Res_WBook_Name = "" ;
for(int i = 0; i < WorkBookName.length(); i++ )
{
if(WorkBookName.charAt(i)=='\\')
{
Res_WBook_Name = Res_WBook_Name + "\\\\";
}
else
{
Res_WBook_Name =Res_WBook_Name + WorkBookName.charAt(i);
}
}

try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbcdbcriver={Mic rosoft Excel Driver (*.xls)};" +
"DBQ=" + Res_WBook_Name +
";DriverID=22;READONLY=false","","");

dbmd = con.getMetaData();
st = con.createStatement();


rs = dbmd.getTables(null, null, null, null);
int i=0;
while( rs.next())
{
System.out.println(rs.getString(3));
}

}catch(Exception ex)
{
System.err.print("Exception: ");
System.err.println(ex.getMessage());
}




The input to this program is "Book1.xls". This workbook contain only 2 sheets named,

Msg-Inbox
Msg-Outbox.


and the actual output is ..

'Msg-Inbox$'
'Msg-Inbox$'_
'Msg-Inbox$'Z_59F1344A_26F2_42CC_88F6_3FDC53DADE60_#wvu #FilterDa
'Msg-Inbox$'Z_B2FA8073_FE79_46BA_9326_53C6CF8873E5_#wvu #FilterDa
'Msg-Outbox$'
'Msg-Outbox$'_
'Msg-Outbox$'Z_59F1344A_26F2_42CC_88F6_3FDC53DADE60_#wv u#FilterD
'Msg-Outbox$'Z_B2FA8073_FE79_46BA_9326_53C6CF8873E5_#wv u#FilterD


What does this means......
and how can i retrieve the table name along...

Please help meeee.


Thank u.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL Query resultset into Excel Sheet chandpuri Database 6 06-05-2008 03:08 PM
Save data from Excel sheet to servlet chandu.v Java Servlet 2 04-10-2008 02:51 PM
How to set the AutoFilter to Excel Sheet with Wither POI or JXL lnarayana_boga Advanced Java 0 01-29-2008 10:05 AM
no of fonts and cells exceeding error in excel sheet. iimasd AWT / Swing 0 11-06-2007 07:58 AM
JExcel: Copy a cell content from one sheet to another sheet in the same workbook. ukbasak Advanced Java 0 08-02-2007 01:31 PM


All times are GMT +3. The time now is 07:52 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org