Results 1 to 1 of 1
- 03-11-2008, 03:20 PM #1
Member
- Join Date
- Mar 2008
- Posts
- 1
- Rep Power
- 0
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("jdbc:odbc:Driver={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.
Similar Threads
-
SQL Query resultset into Excel Sheet
By chandpuri in forum JDBCReplies: 8Last Post: 01-24-2011, 07:53 PM -
Save data from Excel sheet to servlet
By chandu.v in forum Java ServletReplies: 2Last Post: 04-10-2008, 02:51 PM -
How to set the AutoFilter to Excel Sheet with Wither POI or JXL
By lnarayana_boga in forum Advanced JavaReplies: 0Last Post: 01-29-2008, 10:05 AM -
no of fonts and cells exceeding error in excel sheet.
By iimasd in forum AWT / SwingReplies: 0Last Post: 11-06-2007, 07:58 AM -
JExcel: Copy a cell content from one sheet to another sheet in the same workbook.
By ukbasak in forum Advanced JavaReplies: 0Last Post: 08-02-2007, 01:31 PM
Bookmarks