in reply to Parsing Excel Files?
I am doing it currently using ODBC and DBI.
# Set the DSN for ODBC connection my $DSN = "driver=Microsoft Excel Driver (*.xls);dbq=$SpreadShe +et"; # Connect to the Spread Sheet my $ExcelHandle = DBI ->connect("dbi:ODBC:$DSN", '','') or die "$DBI::errstr\n";
This code will connect using the Excel ODBC driver to the file specified by $SpreadSheet. The tables will be the name of the work sheets.
my $Table = '[Sheet1$]'; # This translates to Sheet1 # This is an example query statement to read a worksheet. my $QueryStatement = "SELECT * FROM $Table"; my $ExcelQuery = $ExcelHandle -> prepare( $QueryStatement ); $ExcelQuery -> execute();
Row one is used for the column names in the table. And the rest of the data can be accessed with SQL queries. I find it works nice. If I am transfering data from spreadsheets to databases I find it easier to work in an all database mindset.
|
|---|