net.sourceforge.squirrel_sql.plugins.dataimport.importer.excel
Class ExcelFileImporter

java.lang.Object
  extended by net.sourceforge.squirrel_sql.plugins.dataimport.importer.excel.ExcelFileImporter
All Implemented Interfaces:
IFileImporter

public class ExcelFileImporter
extends Object
implements IFileImporter

This implementation of the IFileImporter interface is to import Microsoft Excel files.

Author:
Thorsten Mürell

Constructor Summary
ExcelFileImporter(File importFile)
          The standard constructor
 
Method Summary
 boolean close()
          Closes the file.
 JComponent getConfigurationPanel()
          This method returns the panel that is used to configure the importer.
 Date getDate(int column)
          Returns the given column as a date
 Integer getInt(int column)
          Returns the given column as an integer
 Long getLong(int column)
          Returns the given column as a long
 String[][] getPreview(int noOfLines)
          Returns a preview of the importer's data in string format
 int getRows()
          Returns the number of rows in the file.
 String getString(int column)
          Returns the given column as a string
 boolean next()
          Moves the file pointer to the next row.
 boolean open()
          Opens the file.
 boolean reset()
          Resets the file pointer to the first row.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExcelFileImporter

public ExcelFileImporter(File importFile)
The standard constructor

Parameters:
importFile - The import file
Method Detail

open

public boolean open()
             throws IOException
Description copied from interface: IFileImporter
Opens the file. This method has to used in order to read the file.

Specified by:
open in interface IFileImporter
Returns:
true on success, false otherwise
Throws:
IOException - If an I/O error occurs, this exception is thrown

close

public boolean close()
              throws IOException
Description copied from interface: IFileImporter
Closes the file. This method has to be called after you finished reading the file.

Specified by:
close in interface IFileImporter
Returns:
true on success, false otherwise
Throws:
IOException - If an I/O error occurs, this exception is thrown

getPreview

public String[][] getPreview(int noOfLines)
                      throws IOException
Description copied from interface: IFileImporter
Returns a preview of the importer's data in string format

Specified by:
getPreview in interface IFileImporter
Parameters:
noOfLines - The lines to return
Returns:
A table with noOfLines rows
Throws:
IOException - If an error reading the import file occurred.

reset

public boolean reset()
              throws IOException
Description copied from interface: IFileImporter
Resets the file pointer to the first row.

Specified by:
reset in interface IFileImporter
Returns:
true on success, false otherwise
Throws:
IOException - If an I/O error occurs, this exception is thrown

getRows

public int getRows()
Description copied from interface: IFileImporter
Returns the number of rows in the file.

Specified by:
getRows in interface IFileImporter
Returns:
The number of rows in the file or -1 if the value is unknown.

next

public boolean next()
             throws IOException
Description copied from interface: IFileImporter
Moves the file pointer to the next row.

Specified by:
next in interface IFileImporter
Returns:
true on success, false otherwise
Throws:
IOException - If an I/O error occurs, this exception is thrown

getString

public String getString(int column)
                 throws IOException
Description copied from interface: IFileImporter
Returns the given column as a string

Specified by:
getString in interface IFileImporter
Parameters:
column - The column number to retrieve
Returns:
The string value of the column
Throws:
IOException - If an I/O error occurs, this exception is thrown

getInt

public Integer getInt(int column)
               throws IOException,
                      UnsupportedFormatException
Description copied from interface: IFileImporter
Returns the given column as an integer

Specified by:
getInt in interface IFileImporter
Parameters:
column - The column number to retrieve
Returns:
The integer value of the column
Throws:
IOException - If an I/O error occurs, this exception is thrown
UnsupportedFormatException - If the column cannot be converted to an integer

getDate

public Date getDate(int column)
             throws IOException,
                    UnsupportedFormatException
Description copied from interface: IFileImporter
Returns the given column as a date

Specified by:
getDate in interface IFileImporter
Parameters:
column - The column number to retrieve
Returns:
The date value of the column
Throws:
IOException - If an I/O error occurs, this exception is thrown
UnsupportedFormatException - If the column cannot be converted to a date

getLong

public Long getLong(int column)
             throws IOException,
                    UnsupportedFormatException
Description copied from interface: IFileImporter
Returns the given column as a long

Specified by:
getLong in interface IFileImporter
Parameters:
column - The column number to retrieve
Returns:
The long value of the column
Throws:
IOException - If an I/O error occurs, this exception is thrown
UnsupportedFormatException - If the column cannot be converted to a long

getConfigurationPanel

public JComponent getConfigurationPanel()
Description copied from interface: IFileImporter
This method returns the panel that is used to configure the importer. The importer is not required to show this panel. So you should provide reasonable defaults for the setting values. E.g. the importer can ask for columns seperators.

Specified by:
getConfigurationPanel in interface IFileImporter
Returns:
The panel to include in the question dialog. Return null to signal, that no configuration is possible and no dialog should be shown.


Copyright © 2001-2011. All Rights Reserved.