You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
2.1 KiB

/*
* Importer.java
*
* Created on 7 de Abril de 2004, 10:56
*/
package siprp.importer;
import com.evolute.utils.arrays.*;
import com.evolute.utils.tables.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
import javax.swing.table.*;
import jxl.*;
/**
*
* @author psantos
*/
public class Importer extends JFrame
{
private JPanel panel;
/** Creates a new instance of Importer */
public Importer( String filename )
throws Exception
{
System.out.println( "File: " + filename );
setupComponents( filename );
addWindowListener( new WindowAdapter(){
public void windowClosing( WindowEvent e )
{
System.exit( 0 );
}
} );
}
private void setupComponents( String filename )
{
setSize( 100, 100 );
panel = ( JPanel ) getContentPane();
Excel2DArray e2da = new Excel2DArray( filename );
Virtual2DTableModel tm = new Virtual2DTableModel( new String[ e2da.rowLength() ], null );
tm.setValues( e2da );
BaseTable table = new BaseTable( tm );
for( int i = 0; i < e2da.rowLength(); i++ )
{
table.getColumn( i ).setMinWidth( 50 );
table.getColumn( i ).setResizable( true );
}
// TableColumn col = table.getColumnModel().getColumn( 0 );
// col.setHeaderRenderer( new ComboBoxHeaderRenderer() );
JScrollPane sp = new JScrollPane( table, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
panel.add( sp );
}
public static void main( String args[] )
{
Importer im = null;
try
{
im = new Importer(
// "E:\\test.xls"
"C:\\Documents and Settings\\psantos\\My Documents\\Devel\\teste_2.xls"
// "C:\\Documents and Settings\\psantos\\My Documents\\Devel\\Docs\\jexcelapi\\jxlrwtest.xls"
);
}
catch( Exception e )
{
e.printStackTrace();
}
if( im == null )
{
System.out.println( "O im e' null" );
}
else
{
im.show();
}
// String[][] all = (String[][]) e.getObjects();
//
// for( int j = 0; j < e.rowLength(); j++ )
// {
// String[] r = e.getRow( j );
// for( int i = 0; i < r.length; i++ )
// {
// System.out.print( "[" + r[ i ] + "]" );
// }
// System.out.println();
// }
}
}