Revision 2093

View differences:

org.gvsig.jexcel/tags/org.gvsig.jexcel-1.0.238/org.gvsig.jexcel.app/org.gvsig.jexcel.app.mainplugin/buildNumber.properties
1
#Sun Mar 03 23:51:28 CET 2024
2
buildNumber=243
org.gvsig.jexcel/tags/org.gvsig.jexcel-1.0.238/org.gvsig.jexcel.app/org.gvsig.jexcel.app.mainplugin/src/main/userdoc/user_manual.rst
1
jexcel plugin user manual v0.2
2
=================================
3

  
4
.. contents:: Contents
5

  
6
Introduction
7
--------------
8

  
9
The jexcel plugin add to gvSIG the following functionalities:
10

  
11
* Load Microsoft Excel spreadsheets as tables.
12
* Load Microsoft Excel spreadsheets as layers.
13
* Export a table to Excel spreadsheet format.
14

  
15
It supports the following Excel spreadsheet versions:
16

  
17
* Reading: Excel 95, 97, 2000, XP, and 2003 workbooks.
18
* Writing: Excel 2000
19

  
20
Installation
21
--------------
22

  
23
(TODO)
24

  
25
Loading a table from an Excel spreadsheet
26
------------------------------------------
27

  
28
From the gvSIG project manager, select the “Table” document (1) and click on “New” (2). In the “New table” window the “File” tab is selected by default. Click on “Add” (3) and find the Excel file that contains the spreadsheet you want to load (4). Finally click on “Open” (5).
29

  
30
|
31

  
32
.. image:: Selection_088.png
33
  :align: center
34
  :scale: 150
35

  
36
Once the file appears in the “New table” window, click on “Properties” (7) in order to set up the following parameters:
37

  
38
Data source properties
39
+++++++++++++++++++++++
40

  
41
General tab (default)
42
^^^^^^^^^^^^^^^^^^^^^^
43

  
44
 - **File:** File path.
45
 - **Locale:** Localization configuration. This determines the characters used as decimal and thousands separators.
46
 - **Sheet to load:** Position within the spreadsheet file of the sheet that we want to load. First position corresponds with the number "0", second with "1" and so on.
47
 - **Use first row as header:** In case this option is checked it will consider the first row values as the field names.
48
 - **CRS:** In case the sheet contains coordinates this parameter sets its Coordinate Reference System.
49
 - **Point (X,Y,Z):** Position of the fields that contains the coordinates. It should be provided at least two fields for X,Y coordinates.
50

  
51
|
52

  
53
.. image:: Selection_091.png
54
  :align: center
55
  :scale: 150
56

  
57
Advanced tab
58
^^^^^^^^^^^^^^
59

  
60
 - **ProviderName:** The provider name (internal use).
61
 - **Header:** In case the sheet doesn't have a header we can define it here. We have to type the name of the fields separated by a comma.
62
 - **Field types:** The is useful if we want to force the program to load the table with a specific field types. 
63
 - **Automatic types detection:** This options is checked by default. It tryes to figure out what the field types are. 
64
 - **Ignore errors:** This option forces the program to load the table even in case it finds erros.
65

  
66
|
67

  
68
.. image:: Selection_090.png
69
  :align: center
70
  :scale: 150
71

  
72
Once all the needed parameters have been set up click on “Accept” and finally on “Ok”. If everything worked fine the table should appear.
73

  
74
|
75

  
76
.. image:: Selection_092.png
77
  :align: center
78
  :scale: 150
79

  
80
Loading a layer from an Excel Spreadsheet
81
------------------------------------------
82

  
83
From the gvSIG project manager, select the “View” document (1) and click on “New” (2). In the “Add layer” window the “File” tab is selected by default. Click on “Add” (4) and find the Excel file that contains the spreadsheet you want to load (5). Finally click on “Open” (6).
84

  
85
|
86

  
87
.. image:: Selection_095.png
88
  :align: center
89
  :scale: 150
90

  
91
Once the file appears in the “Add layer” window, click on “Properties” (7) in order to set up the following parameters:
92

  
93
Data source properties
94
+++++++++++++++++++++++
95

  
96
General tab (default)
97
^^^^^^^^^^^^^^^^^^^^^^
98

  
99
 - **File:** File path.
100
 - **Locale:** Localization configuration. This determines the characters used as decimal and thousands separators.
101
 - **Sheet to load:** Position within the spreadsheet file of the sheet that we want to load. First position corresponds with the number "0", second with "1" and so on.
102
 - **Use first row as header:** In case this option is checked it will consider the first row values as the field names.
103
 - **CRS:** In case the sheet contains coordinates this parameter sets its Coordinate Reference System.
104
 - **Point (X,Y,Z):** Position of the fields that contains the coordinates. It should be provided at least two fields for X,Y coordinates.
105

  
106
|
107

  
108
.. image:: Selection_096.png
109
  :align: center
110
  :scale: 150
111

  
112
Advanced tab
113
^^^^^^^^^^^^^^
114

  
115
 - **ProviderName:** The provider name (internal use).
116
 - **Header:** In case the sheet doesn't have a header we can define it here. We have to type the name of the fields separated by a comma.
117
 - **Field types:** The is useful if we want to force the program to load the table with a specific field types. 
118
 - **Automatic types detection:** This options is checked by default. It tryes to figure out what the field types are. 
119
 - **Ignore errors:** This option forces the program to load the table even in case it finds erros.
120

  
121
|
122

  
123
.. image:: Selection_097.png
124
  :align: center
125
  :scale: 150
126

  
127
Once all the needed parameters have been set up click on “Accept” and finally on “Ok”. If everything worked fine the layer should appear in the view.
128

  
129
|
130

  
131
.. image:: Selection_098.png
132
  :align: center
133
  :scale: 150
134

  
135
Exporting a table to Excel spreadsheet format
136
----------------------------------------------
137

  
138
(TODO)
org.gvsig.jexcel/tags/org.gvsig.jexcel-1.0.238/org.gvsig.jexcel.app/org.gvsig.jexcel.app.mainplugin/src/main/resources-plugin/test1.txt
1
>>> from  jxl import Workbook
2
>>> Workbook.getWorkbook
3
<java function getWorkbook 1>
4
>>> from java.io import File
5
>>> f=File("/home/usuario/datos/geodata/tables/torrent_4-es-excel2003.xls")
6
>>> f.exists()
7
1
8
>>> w=Workbook.getWorkbook(f)
9
>>> dir(w)
10
['XCTRecords', 'addInFunctionNames', 'buttonPropertySet', 'class', 'close', 'compoundFile', 'containsMacros', 'countryRecord', 'createWorkbook', 'drawingGroup', 'equals', 'externalSheetRecord', 'findByName', 'findCellByName', 'fonts', 'formattingRecords', 'getAddInFunctionNames', 'getButtonPropertySet', 'getCell', 'getClass', 'getCompoundFile', 'getCountryRecord', 'getDrawingGroup', 'getExternalSheetIndex', 'getExternalSheetName', 'getExternalSheetRecord', 'getFonts', 'getFormattingRecords', 'getIndex', 'getLastExternalSheetIndex', 'getLastExternalSheetName', 'getMsoDrawingGroupRecord', 'getName', 'getNameIndex', 'getNameRecords', 'getNumberOfSheets', 'getRangeNames', 'getReadSheet', 'getSettings', 'getSheet', 'getSheetNames', 'getSheets', 'getSupbookRecords', 'getVersion', 'getWorkbook', 'getWorkbookBof', 'getXCTRecords', 'hashCode', 'isProtected', 'msoDrawingGroupRecord', 'nameRecords', 'notify', 'notifyAll', 'numberOfSheets', 'protected', 'rangeNames', 'settings', 'sheetNames', 'sheets', 'supbookRecords', 'toString', 'wait', 'workbookBof']
11
>>> w.numberOfSheets
12
1
13
>>> w.sheetNames
14
array(java.lang.String,['Hoja1']) 
15
>>> w.sheets
16
array(jxl.Sheet,[jxl.read.biff.SheetImpl@3a4f51e8]) 
17
>>> s=w.sheets[0]
18
>>> s
19
jxl.read.biff.SheetImpl@3a4f51e8
20
>>> dir(s)
21
['PLS', 'autoFilter', 'buttonPropertySet', 'charts', 'class', 'columnInfos', 'columnPageBreaks', 'columns', 'conditionalFormats', 'dataValidation', 'drawingData', 'drawings', 'equals', 'findCell', 'findLabelCell', 'getAutoFilter', 'getButtonPropertySet', 'getCell', 'getCharts', 'getClass', 'getColumn', 'getColumnFormat', 'getColumnInfo', 'getColumnInfos', 'getColumnPageBreaks', 'getColumnView', 'getColumnWidth', 'getColumns', 'getConditionalFormats', 'getDataValidation', 'getDrawing', 'getDrawingData', 'getDrawings', 'getHyperlinks', 'getMaxColumnOutlineLevel', 'getMaxRowOutlineLevel', 'getMergedCells', 'getName', 'getNumberOfImages', 'getPLS', 'getRow', 'getRowHeight', 'getRowPageBreaks', 'getRowProperties', 'getRowView', 'getRows', 'getSettings', 'getSheetBof', 'getWorkbook', 'getWorkbookBof', 'getWorkspaceOptions', 'hashCode', 'hidden', 'hyperlinks', 'isHidden', 'isProtected', 'maxColumnOutlineLevel', 'maxRowOutlineLevel', 'mergedCells', 'name', 'notify', 'notifyAll', 'numberOfImages', 'protected', 'rowPageBreaks', 'rowProperties', 'rows', 'settings', 'sheetBof', 'toString', 'wait', 'workbook', 'workbookBof', 'workspaceOptions']
22
>>> 
23
>>> s.getRows()
24
382
25
>>> s.columns
26
5
27
>>> 
28
>>> c=s.getCell(0,0)
29
>>> dir(c)
30
['XFIndex', 'cellFeatures', 'cellFormat', 'class', 'column', 'contents', 'equals', 'getCellFeatures', 'getCellFormat', 'getClass', 'getColumn', 'getContents', 'getRow', 'getString', 'getType', 'getXFIndex', 'hashCode', 'hidden', 'isHidden', 'notify', 'notifyAll', 'row', 'setCellFeatures', 'string', 'toString', 'type', 'wait']
31
>>> 
32
>>> c.toString()
33
'jxl.read.biff.LabelSSTRecord@14a614b5'
34
>>> c.contents
35
'B1'
36
>>> 
37
>>> s.getCell(0,s.getRows()-1)
38
jxl.read.biff.NumberValue@3e803098
39
>>> s.getCell(s.columns-1,s.getRows()-1)
40
jxl.read.biff.LabelSSTRecord@56dc16be
41
>>> s.getCell(s.columns-1,s.getRows()-1).contents
42
'R'
43
>>> 
44

  
45

  
46

  
47

  
48

  
49

  
50

  
51

  
52

  
org.gvsig.jexcel/tags/org.gvsig.jexcel-1.0.238/org.gvsig.jexcel.app/org.gvsig.jexcel.app.mainplugin/src/main/resources-plugin/config.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<plugin-config>
3
  <libraries library-dir="lib/"/>
4
  <depends plugin-name="org.gvsig.app.mainplugin"/>
5
  <resourceBundle name="text"/>
6
  <extensions>
7
     <extension class-name="org.gvsig.andami.LibraryExtension" active="false"/>
8
  </extensions>
9
</plugin-config>
org.gvsig.jexcel/tags/org.gvsig.jexcel-1.0.238/org.gvsig.jexcel.app/org.gvsig.jexcel.app.mainplugin/src/main/assembly/gvsig-plugin-package.xml
1
<assembly>
2
  <id>gvsig-plugin-package</id>
3
  <formats>
4
    <format>zip</format>
5
  </formats>
6
  <baseDirectory>${project.artifactId}</baseDirectory>
7
  <includeBaseDirectory>true</includeBaseDirectory>
8
  <files>
9
    <file>
10
      <source>target/${project.artifactId}-${project.version}.jar</source>
11
      <outputDirectory>lib</outputDirectory>
12
    </file>
13
    <file>
14
      <source>target/package.info</source>
15
    </file>
16
  </files>
17

  
18
  <fileSets>
19
    <fileSet>
20
      <directory>src/main/resources-plugin</directory>
21
      <outputDirectory>.</outputDirectory>
22
    </fileSet>
23
  </fileSets>
24

  
25
  <dependencySets>
26
  
27
    <dependencySet>
28
      <useProjectArtifact>false</useProjectArtifact>
29
      <useTransitiveDependencies>false</useTransitiveDependencies>
30
      <outputDirectory>lib</outputDirectory>
31
      <includes>
32
        <include>net.sourceforge.jexcelapi:jxl</include>
33
        <include>org.gvsig:org.gvsig.jexcel.provider</include>        
34
      </includes>
35
    </dependencySet>
36
    
37
  </dependencySets>
38

  
39
</assembly>
org.gvsig.jexcel/tags/org.gvsig.jexcel-1.0.238/org.gvsig.jexcel.app/org.gvsig.jexcel.app.mainplugin/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3
    <modelVersion>4.0.0</modelVersion>
4
    <artifactId>org.gvsig.jexcel.app.mainplugin</artifactId>
5
    <packaging>jar</packaging>
6
    <name>${project.artifactId}</name>
7
    <description>Excel file format support</description>
8
    <parent>
9
        <groupId>org.gvsig</groupId>
10
        <artifactId>org.gvsig.jexcel.app</artifactId>
11
        <version>1.0.238</version>
12
    </parent>
13

  
14
    <dependencies>
15
        <dependency>
16
            <groupId>org.gvsig</groupId>
17
            <artifactId>org.gvsig.tools.lib</artifactId>
18
            <scope>compile</scope>
19
        </dependency>
20
        <dependency>
21
            <groupId>org.gvsig</groupId>
22
            <artifactId>org.gvsig.andami</artifactId>
23
            <scope>compile</scope>
24
        </dependency>
25
        <dependency>
26
            <groupId>org.gvsig</groupId>
27
            <artifactId>org.gvsig.jexcel.provider</artifactId>
28
            <scope>compile</scope>
29
        </dependency>
30

  
31
        <dependency>
32
            <groupId>net.sourceforge.jexcelapi</groupId>
33
            <artifactId>jxl</artifactId>
34
            <scope>compile</scope>
35
        </dependency>
36

  
37
    </dependencies>
38

  
39
    <properties>
40
        <!-- Package info property values -->
41
        <!-- Default values in org.gvsig.desktop -->
42
        <gvsig.package.info.name>Formats: Excel file format support</gvsig.package.info.name>
43
        <gvsig.package.info.state>testing</gvsig.package.info.state>
44
        <gvsig.package.info.official>true</gvsig.package.info.official>
45
        <gvsig.package.info.dependencies>required: org.gvsig.app.mainplugin -ge 2.1.0-A</gvsig.package.info.dependencies>
46
        <gvsig.package.info.categories>Formats,Vector</gvsig.package.info.categories>
47
        <gvsig.package.info.poolURL>https://devel.gvsig.org/download/projects/gvsig-jexcel/pool/</gvsig.package.info.poolURL>
48
    </properties>
49

  
50
</project>
0 51

  
org.gvsig.jexcel/tags/org.gvsig.jexcel-1.0.238/org.gvsig.jexcel.app/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3
  <modelVersion>4.0.0</modelVersion>
4
  <artifactId>org.gvsig.jexcel.app</artifactId>
5
  <packaging>pom</packaging>
6
  <name>${project.artifactId}</name>
7
  <parent>
8
      <groupId>org.gvsig</groupId>
9
      <artifactId>org.gvsig.jexcel</artifactId>
10
      <version>1.0.238</version>
11
  </parent>
12

  
13
  <modules>
14
    <module>org.gvsig.jexcel.app.mainplugin</module>
15
  </modules>
16

  
17

  
18
</project>
org.gvsig.jexcel/tags/org.gvsig.jexcel-1.0.238/org.gvsig.jexcel.provider/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2

  
3
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4

  
5
    <modelVersion>4.0.0</modelVersion>
6
    <artifactId>org.gvsig.jexcel.provider</artifactId>
7
    <packaging>jar</packaging>
8
    <name>${project.artifactId}</name>
9
    <description>DAL provider for Excel files</description>
10
    <parent>
11
        <groupId>org.gvsig</groupId>
12
        <artifactId>org.gvsig.jexcel</artifactId>
13
        <version>1.0.238</version>
14
    </parent>
15

  
16
    <dependencies>
17

  
18
        <dependency>
19
            <groupId>commons-io</groupId>
20
            <artifactId>commons-io</artifactId>
21
            <scope>compile</scope>
22
        </dependency>
23

  
24
        <dependency>
25
            <groupId>org.apache.commons</groupId>
26
            <artifactId>commons-lang3</artifactId>
27
            <scope>compile</scope>
28
        </dependency>
29

  
30
        <dependency>
31
            <groupId>org.gvsig</groupId>
32
            <artifactId>org.gvsig.tools.lib</artifactId>
33
            <scope>compile</scope>
34
        </dependency>
35
        <dependency>
36
            <groupId>org.gvsig</groupId>
37
            <artifactId>org.gvsig.projection.api</artifactId>
38
            <scope>compile</scope>
39
        </dependency>
40
        <dependency>
41
            <groupId>org.gvsig</groupId>
42
            <artifactId>org.gvsig.fmap.dal.api</artifactId>
43
            <scope>compile</scope>
44
        </dependency>
45
        <dependency>
46
            <groupId>org.gvsig</groupId>
47
            <artifactId>org.gvsig.fmap.dal.file.lib</artifactId>
48
            <scope>compile</scope>
49
        </dependency>
50
        <dependency>
51
            <groupId>org.gvsig</groupId>
52
            <artifactId>org.gvsig.fmap.dal.spi</artifactId>
53
            <scope>compile</scope>
54
        </dependency>
55
        <dependency>
56
            <groupId>org.gvsig</groupId>
57
            <artifactId>org.gvsig.metadata.lib.basic.api</artifactId>
58
            <scope>compile</scope>
59
        </dependency>
60
        <dependency>
61
            <groupId>org.gvsig</groupId>
62
            <artifactId>org.gvsig.fmap.geometry.api</artifactId>
63
            <scope>compile</scope>
64
        </dependency>
65
        <dependency>
66
            <groupId>org.gvsig</groupId>
67
            <artifactId>org.gvsig.timesupport.lib.api</artifactId>
68
            <scope>compile</scope>
69
        </dependency>  
70
        <dependency>
71
            <groupId>org.gvsig</groupId>
72
            <artifactId>org.gvsig.utils</artifactId>
73
            <scope>compile</scope>
74
        </dependency>
75
        <dependency>
76
            <groupId>org.gvsig</groupId>
77
            <artifactId>org.gvsig.tools.dynform.api</artifactId>
78
            <scope>compile</scope>
79
        </dependency>
80
        <dependency>
81
            <groupId>org.gvsig</groupId>
82
            <artifactId>org.gvsig.tools.dynform.spi</artifactId>
83
            <scope>compile</scope>
84
        </dependency>
85
        <dependency>
86
            <groupId>org.gvsig</groupId>
87
            <artifactId>org.gvsig.tools.dynform.services</artifactId>
88
            <scope>compile</scope>
89
        </dependency>
90
        <dependency>
91
            <groupId>com.jgoodies</groupId>
92
            <artifactId>jgoodies-forms</artifactId>
93
            <scope>compile</scope>
94
        </dependency>
95

  
96
        <dependency>
97
            <groupId>net.sourceforge.jexcelapi</groupId>
98
            <artifactId>jxl</artifactId>
99
            <scope>compile</scope>
100
        </dependency>
101

  
102

  
103
        <!-- TESTS -->
104
        <dependency>
105
            <groupId>org.gvsig</groupId>
106
            <artifactId>org.gvsig.tools.lib</artifactId>
107
            <type>test-jar</type>
108
            <scope>test</scope>
109
        </dependency>
110
        <dependency>
111
            <groupId>org.gvsig</groupId>
112
            <artifactId>org.gvsig.compat.se</artifactId>
113
            <scope>test</scope>
114
        </dependency>
115
        <dependency>
116
            <groupId>org.gvsig</groupId>
117
            <artifactId>org.gvsig.fmap.dal.impl</artifactId>
118
            <type>test-jar</type>
119
            <scope>test</scope>
120
        </dependency>
121
        <dependency>
122
            <groupId>org.gvsig</groupId>
123
            <artifactId>org.gvsig.projection.cresques.impl</artifactId>
124
            <scope>test</scope>
125
        </dependency>
126
        <dependency>
127
            <groupId>org.gvsig</groupId>
128
            <artifactId>org.gvsig.timesupport.lib.impl</artifactId>
129
            <scope>test</scope>
130
        </dependency>
131
    </dependencies>
132
  
133
    <build>
134
        <plugins>
135
            <plugin>
136
                <!-- Skip compilation tests -->
137
                <groupId>org.apache.maven.plugins</groupId>
138
                <artifactId>maven-compiler-plugin</artifactId>
139
                <executions>
140
                    <execution>
141
                        <id>default-testCompile</id>
142
                        <phase>process-test-sources</phase>
143
                        <goals>
144
                            <goal>testCompile</goal>
145
                        </goals>
146
                        <configuration>
147
                            <skip>true</skip>
148
                        </configuration>
149
                    </execution>
150
                </executions>
151
            </plugin>
152
        </plugins>
153
    </build>
154
    
155
</project>
org.gvsig.jexcel/tags/org.gvsig.jexcel-1.0.238/org.gvsig.jexcel.provider/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.jexcel.JExcelLibrary
org.gvsig.jexcel/tags/org.gvsig.jexcel-1.0.238/org.gvsig.jexcel.provider/src/main/resources/org/gvsig/jexcel/dal/provider/JExcelMetadata.xml
1
<?xml version="1.0"?>
2
<!--
3
Definitions of metadata fields of a shp file.  
4
 -->
5
<definitions>
6
  <version>1.0.0</version>
7
  <classes>
8
    
9
    <class name="JExcel" namespace="Metadata">
10
      <extends>
11
      	<class namespace="Metadata" name="SpatialProvider"/>
12
      </extends>
13
      <description>Metadata of a JExcel store</description>
14
      <fields>
15
      </fields>
16
    </class>
17

  
18
  </classes>
19
</definitions>  
org.gvsig.jexcel/tags/org.gvsig.jexcel-1.0.238/org.gvsig.jexcel.provider/src/main/resources/org/gvsig/jexcel/dal/provider/JExcelParameters.xml
1
<?xml version= "1.0 "?>
2
<definitions>
3
    <version>1.0.0</version>
4
    <classes>
5
        <class name="JExcel">
6
            <extends>
7
                <class namespace="dal" name="ProviderParameters"/>
8
            </extends>
9
            <description>Store the parameters need to open a Excel file</description>
10
            <fields>
11
                <field name="file" label="File" type="file" mandatory="true">
12
                    <description>Excel file</description>
13
                </field>
14
                <field name="locale" label="Locale" type="string" mandatory="true" defaultValue="DEFAULT">
15
                    <description>Locale used to parse double and float values (BCP47 language tag representing the locale)</description>
16
                    <availableValues>
17
                        <value label="Default (use system locale)">DEFAULT</value>
18
                        <value label="Canada (english)">en-CA</value>
19
                        <value label="Canada (french)">fr-CA</value>
20
                        <value label="Chinese">zh</value>
21
                        <value label="English">en</value>
22
                        <value label="French">fr</value>
23
                        <value label="German">de</value>
24
                        <value label="Italian">it</value>
25
                        <value label="Japanese">ja</value>
26
                        <value label="Korea">ko</value>
27
                        <value label="Spain">es</value>
28
                        <value label="Uk">en-GB</value>
29
                        <value label="Us">en-US</value>
30
                    </availableValues>          
31
                </field>
32
                <field name="sheet" label="Sheet to load" type="integer" subtype="jexcel.sheet.selector" mandatory="false" defaultValue="0">
33
                    <description>Sheet to use.</description>
34
                </field>
35
                <field name="isFirstRowHeadeer" label="Use first row as header" type="boolean" mandatory="false" defaultValue="false">
36
                    <description>Check for use first row as header.</description>
37
                </field>
38
                <field name="CRS" type="crs" mandatory="false">
39
                    <description>The coordinate reference system used when use the point parameter to generate a layer</description>
40
                </field>
41
                <field name="point" label="Point (X,Y,Z)" type="string" mandatory="false" defaultValue="" >
42
                    <description>This field allow to add a Geometry column to the table. It is a list of field names separated by commas used as dimensions for the attribute GEOM of type point to add to the table.</description>
43
                </field>
44

  
45
                <field name="header" label="Header" type="string" mandatory="false" defaultValue="" group="Advanced">
46
                    <description>The header or empty if parsed automatically</description>
47
                </field>
48
                <field name="fieldtypes" label="Field types" type="string" mandatory="false" defaultValue="" group="Advanced">
49
                    <description>Comma separated list of field types. If empty strings are assumed (Eg: integer,string,double,boolean,float,geometry).</description>
50
                </field>
51
                <field name="automaticTypesDetection" label="Automatic types detection" type="boolean" mandatory="false" defaultValue="true" group="Advanced">
52
                    <description>This flag activate the autodetection of types in the CSV. Can be slow.</description>
53
                </field>
54
                <field name="ignoreErrors" label="Ignore errors" type="boolean" mandatory="false" defaultValue="false" group="Advanced">
55
                    <description>Set to true to ignore errors during load of data.</description>
56
                </field>
57
            </fields>
58
      
59
        </class>
60
    </classes>
61
</definitions>  
org.gvsig.jexcel/tags/org.gvsig.jexcel-1.0.238/org.gvsig.jexcel.provider/src/main/java/org/gvsig/jexcel/Spread.java
1
package org.gvsig.jexcel;
2

  
3
import java.awt.Rectangle;
4
import java.io.File;
5
import java.util.List;
6

  
7
/**
8
 *
9
 * @author jjdelcerro
10
 */
11
public interface Spread {
12

  
13
    public static String NAME = "Excel";
14

  
15
    public static Spread create(File file, Object... args) {
16
        JExcelSpread spread = new JExcelSpread();
17
        spread.open(file);
18
        return spread;
19
    }
20

  
21
    public interface Sheet {
22

  
23
        int getColumnCount();
24

  
25
        List<String> getColumnNames(boolean isFirstLineHedaer);
26

  
27
        File getFile();
28

  
29
        String getName();
30

  
31
        int getRowCount();
32

  
33
        int getSheetIndex();
34

  
35
        Object getValueAt(int col, int row);
36

  
37
        public Rectangle getUsedRange();
38
    }
39

  
40
    public void open(File spreadFile);
41

  
42
    public File getFile();
43

  
44
    public Sheet getSheet(int sheetIndex);
45

  
46
    public List<String> getSheetNames();
47
}
org.gvsig.jexcel/tags/org.gvsig.jexcel-1.0.238/org.gvsig.jexcel.provider/src/main/java/org/gvsig/jexcel/JExcelLibrary.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.jexcel;
25

  
26
import java.util.ArrayList;
27
import java.util.List;
28

  
29
import org.gvsig.fmap.dal.DALFileLibrary;
30
import org.gvsig.fmap.dal.DALFileLocator;
31
import org.gvsig.fmap.dal.DALLibrary;
32
import org.gvsig.fmap.dal.DALLocator;
33
import org.gvsig.fmap.dal.FileHelper;
34
import org.gvsig.fmap.dal.spi.DataManagerProviderServices;
35
import org.gvsig.jexcel.dal.provider.JExcelFilesystemServerProvider;
36
import org.gvsig.jexcel.dal.provider.JExcelStoreParameters;
37
import org.gvsig.jexcel.dal.provider.JExcelStoreProvider;
38
import org.gvsig.jexcel.dal.provider.JExcelStoreProviderFactory;
39
import org.gvsig.jexcel.dynformfield.point.JDynFormFieldExcelPointFieldsFactory;
40
import org.gvsig.jexcel.dynformfield.sheet.JDynFormFieldExcelSheetFactory;
41
import org.gvsig.metadata.exceptions.MetadataException;
42
import org.gvsig.tools.dynform.spi.DynFormSPILocator;
43
import org.gvsig.tools.dynform.spi.DynFormSPIManager;
44
import org.gvsig.tools.library.AbstractLibrary;
45
import org.gvsig.tools.library.LibraryException;
46

  
47
public class JExcelLibrary extends AbstractLibrary {
48

  
49
    @Override
50
    public void doRegistration() {
51
        registerAsServiceOf(DALLibrary.class);
52
        require(DALFileLibrary.class);
53
    }
54

  
55
    @Override
56
    protected void doInitialize() throws LibraryException {
57
    }
58

  
59
    @Override
60
    protected void doPostInitialize() throws LibraryException {
61
        List<Throwable> exs = new ArrayList<Throwable>();
62

  
63
        FileHelper.registerParametersDefinition(
64
                JExcelStoreParameters.PARAMETERS_DEFINITION_NAME,
65
                JExcelStoreParameters.class, "JExcelParameters.xml");
66
        try {
67
            FileHelper.registerMetadataDefinition(
68
                    JExcelStoreProvider.METADATA_DEFINITION_NAME,
69
                    JExcelStoreProvider.class, "JExcelMetadata.xml");
70
        } catch (MetadataException e) {
71
            exs.add(e);
72
        }
73

  
74
        DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator
75
                .getDataManager();
76

  
77
        try {
78
            if (!dataman.getStoreProviders().contains(JExcelStoreProvider.NAME)) {
79
                dataman.registerStoreProviderFactory(new JExcelStoreProviderFactory(JExcelStoreProvider.NAME, JExcelStoreProvider.DESCRIPTION));
80

  
81
            }
82
        } catch (RuntimeException e) {
83
            exs.add(e);
84
        }
85

  
86
        try {
87
            DALFileLocator.getFilesystemServerExplorerManager()
88
                    .registerProvider(JExcelStoreProvider.NAME,
89
                            JExcelStoreProvider.DESCRIPTION,
90
                            JExcelFilesystemServerProvider.class);
91
        } catch (RuntimeException e) {
92
            exs.add(e);
93
        }
94

  
95
        DynFormSPIManager manager = DynFormSPILocator.getDynFormSPIManager();
96
        manager.registerDynFieldFactory(new JDynFormFieldExcelSheetFactory());
97
        manager.registerDynFieldFactory(new JDynFormFieldExcelPointFieldsFactory());
98

  
99
        if (exs.size() > 0) {
100
            throw new LibraryException(this.getClass(), exs);
101
        }
102
    }
103
}
org.gvsig.jexcel/tags/org.gvsig.jexcel-1.0.238/org.gvsig.jexcel.provider/src/main/java/org/gvsig/jexcel/dal/provider/JExcelStoreProviderFactory.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.jexcel.dal.provider;
25

  
26
import org.gvsig.fmap.dal.DataParameters;
27
import org.gvsig.fmap.dal.DataStoreProvider;
28
import org.gvsig.fmap.dal.exception.InitializeException;
29
import org.gvsig.fmap.dal.feature.FeatureStoreProviderFactory;
30
import org.gvsig.fmap.dal.feature.spi.AbstractFeatureStoreProviderFactory;
31
import org.gvsig.fmap.dal.spi.DataStoreProviderServices;
32
import org.gvsig.tools.dynobject.DynObject;
33

  
34
public class JExcelStoreProviderFactory extends AbstractFeatureStoreProviderFactory implements FeatureStoreProviderFactory{
35

  
36
	public JExcelStoreProviderFactory(String name, String description) {
37
		super(name, description);
38
	}
39

  
40
	public DataStoreProvider createProvider(DataParameters parameters,
41
			DataStoreProviderServices providerServices)
42
			throws InitializeException {
43
		return new JExcelStoreProvider((JExcelStoreParameters) parameters, providerServices);
44
	}
45

  
46
	public DynObject createParameters() {
47
		return new JExcelStoreParameters();
48
	}
49
	
50
	public int allowCreate() {
51
		return NO;
52
	}
53
	
54
	public int allowWrite() {
55
		return NO;
56
	}
57

  
58
	public int allowRead() {
59
		return YES;
60
	}
61
	
62
	public int hasRasterSupport() {
63
		return NO;
64
	}
65
	
66
	public int hasTabularSupport() {
67
		return YES;
68
	}
69
	
70
	public int hasVectorialSupport() {
71
		return YES;
72
	}
73

  
74
	public int allowMultipleGeometryTypes() {
75
		return YES;
76
	}
77
	
78
	public int allowEditableFeatureType() {
79
		return NO;
80
	}
81

  
82
}
org.gvsig.jexcel/tags/org.gvsig.jexcel-1.0.238/org.gvsig.jexcel.provider/src/main/java/org/gvsig/jexcel/dal/provider/JExcelStoreParameters.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA 02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.jexcel.dal.provider;
25

  
26
import java.io.File;
27
import java.util.Locale;
28
import org.apache.commons.lang3.StringEscapeUtils;
29
import org.apache.commons.lang3.StringUtils;
30
import org.cresques.cts.IProjection;
31
import org.gvsig.fmap.dal.FileHelper;
32
import org.gvsig.fmap.dal.feature.OpenFeatureStoreParameters;
33
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters;
34
import org.gvsig.fmap.dal.spi.AbstractDataStoreParameters;
35
import org.gvsig.fmap.dal.spi.DataStoreProviderServices;
36
import org.gvsig.tools.ToolsLocator;
37
import org.gvsig.tools.dataTypes.DataTypesManager;
38
import org.gvsig.tools.dynobject.DelegatedDynObject;
39
import org.gvsig.tools.dynobject.DynObject;
40
import org.slf4j.Logger;
41
import org.slf4j.LoggerFactory;
42

  
43
public class JExcelStoreParameters extends AbstractDataStoreParameters implements
44
        OpenFeatureStoreParameters, FilesystemStoreParameters {
45

  
46
    private static final Logger logger = LoggerFactory.getLogger(JExcelStoreParameters.class);
47

  
48
    public static final String PARAMETERS_DEFINITION_NAME = "JExcel";
49

  
50
    private static final String FILE = "file";
51
    private static final String IGNOREERRORS = "ignoreErrors";
52
    private static final String CRS = "CRS";
53
    private static final String FIELDTYPES = "fieldtypes";
54
    private static final String LOCALE = "locale";
55
    private static final String SHEET = "sheet";
56
    private static final String ISFIRSTROWHEADER = "isFirstRowHeadeer";
57
    private static final String AUTOMATICTYPESDETECTION = "automaticTypesDetection";
58
    private static final String HEADER = "header";
59

  
60
    private DelegatedDynObject parameters;
61

  
62
    public JExcelStoreParameters() {
63
        this(PARAMETERS_DEFINITION_NAME);
64
    }
65

  
66
    protected JExcelStoreParameters(String parametersDefinitionName) {
67
        this(parametersDefinitionName, JExcelStoreProvider.NAME);
68
    }
69

  
70
    public JExcelStoreParameters(String parametersDefinitionName, String name) {
71
        super();
72
        this.parameters = (DelegatedDynObject) FileHelper.newParameters(parametersDefinitionName);
73
        this.setDynValue(DataStoreProviderServices.PROVIDER_PARAMTER_NAME, name);
74
    }
75

  
76
    public String getDataStoreName() {
77
        return (String) this.getDynValue(DataStoreProviderServices.PROVIDER_PARAMTER_NAME);
78
    }
79

  
80
    public String getDescription() {
81
        return this.getDynClass().getDescription();
82
    }
83

  
84
    protected DelegatedDynObject getDelegatedDynObject() {
85
        return parameters;
86
    }
87

  
88
    public boolean isValid() {
89
        if ( getFileName(this) == null ) {
90
            return false;
91
        }
92
        return true;
93
    }
94

  
95
    public File getFile() {
96
        return (File) this.getDynValue(FILE);
97
    }
98

  
99
    public void setFile(File file) {
100
        this.setDynValue(FILE, file);
101
    }
102

  
103
    static IProjection getCRS(DynObject dynobj) {
104
        return (IProjection) dynobj.getDynValue(CRS);
105
    }
106

  
107
    static String getFileName(DynObject dynobj) {
108
        File f = (File) dynobj.getDynValue(FILE);
109
        if ( f == null ) {
110
            return null;
111
        }
112
        return f.getPath();
113
    }
114

  
115
    static File getFile(DynObject dynobj) {
116
        File f = (File) dynobj.getDynValue(FILE);
117
        return f;
118
    }
119

  
120
    static Locale getLocale(DynObject dynobj) {
121
        try {
122
            String s = (String) dynobj.getDynValue(LOCALE);
123
            if ( s.trim().length() == 0 ) {
124
                return null;
125
            }
126
            if ( "DEFAULT".equalsIgnoreCase(s.trim()) ) {
127
                return Locale.getDefault();
128
            }
129
            Locale locale = null;
130
            // locale = Locale.forLanguageTag(s); // Since java 1.7
131
            String[] ss = s.split("-");
132
            switch (ss.length) {
133
            case 1:
134
                locale = new Locale(ss[0]);
135
                break;
136
            case 2:
137
                locale = new Locale(ss[0], ss[1]);
138
                break;
139
            case 3:
140
            default:
141
                locale = new Locale(ss[0], ss[1], ss[2]);
142
                break;
143
            }
144
            return locale;
145
        } catch (Exception ex) {
146
            logger.warn("Can't get locale from JExcel parameters.", ex);
147
            return null;
148
        }
149
    }
150

  
151
    private static String getDelimiter(String line) {
152
        String sep = null;
153
        // Cuiaddo con los ":", los he puesto al final a proposito
154
        // ya que podian estar en la cadena para separar el size
155
        // size de cada tipo.
156
        String seps = ",;-|@#/+$%&!:";
157
        for ( int i = 0; i < seps.length(); i++ ) {
158
            sep = seps.substring(i, 1);
159
            if ( line.contains(seps.substring(i, 1)) ) {
160
                break;
161
            }
162
            sep = null;
163
        }
164
        return sep;
165
    }
166

  
167
    static String[] getPointDimensionNames(DynObject dynobj) {
168
        String s = (String) dynobj.getDynValue("point");
169
        if ( StringUtils.isEmpty(s) ) {
170
            return null;
171
        }
172
        return s.split(",");
173
    }
174

  
175
    static boolean getIgnoreErrors(DynObject dynobj) {
176
        Boolean b = (Boolean) dynobj.getDynValue(IGNOREERRORS);
177
        if ( b == null ) {
178
            return false;
179
        }
180
        return b.booleanValue();
181
    }
182

  
183
    static int[] getFieldTypes(DynObject dynobj) {
184
        String s = (String) dynobj.getDynValue(FIELDTYPES);
185
        if ( StringUtils.isEmpty(s) ) {
186
            return null;
187
        }
188
        String sep = getDelimiter(s);
189
        if ( sep == null ) {
190
            return null;
191
        }
192
        DataTypesManager dataTypeManager = ToolsLocator.getDataTypesManager();
193
        String fieldTypeNames[] = s.split("[" + sep + "]");
194
        int fieldTypes[] = new int[fieldTypeNames.length];
195
        for ( int i = 0; i < fieldTypeNames.length; i++ ) {
196
            s = fieldTypeNames[i].trim();
197
            if ( s.contains(":") ) {
198
                s = s.split(":")[0];
199
            }
200
            fieldTypes[i] = dataTypeManager.getType(s);
201
        }
202
        return fieldTypes;
203
    }
204

  
205
    static int[] getFieldSizes(DynObject dynobj) {
206
        String s = (String) dynobj.getDynValue(FIELDTYPES);
207
        if ( StringUtils.isEmpty(s) ) {
208
            return null;
209
        }
210
        String sep = getDelimiter(s);
211
        if ( sep == null ) {
212
            return null;
213
        }
214
        String fieldTypeNames[] = s.split("[" + sep + "]");
215
        int fieldSizes[] = new int[fieldTypeNames.length];
216
        for ( int i = 0; i < fieldTypeNames.length; i++ ) {
217
            String fieldtype = fieldTypeNames[i].trim();
218
            if ( fieldtype.contains(":") ) {
219
                try {
220
                    s = fieldtype.split(":")[1];
221
                    fieldSizes[i] = Integer.parseInt(s);
222
                } catch (Exception ex) {
223
                    logger.warn("Can't get size of field " + i + " (" + fieldtype + ").", ex);
224
                }
225
            } else {
226
                fieldSizes[i] = 0;
227
            }
228
        }
229
        return fieldSizes;
230
    }
231

  
232
    static int getSheetIndex(DynObject dynobj) {
233
        Integer sheet = (Integer) dynobj.getDynValue(SHEET);
234
        if ( sheet == null ) {
235
            return 0;
236
        }
237
        return sheet.intValue();
238
    }
239

  
240
    static String getHeader(DynObject dynobj) {
241
        String s = (String) dynobj.getDynValue(HEADER);
242
        s = StringEscapeUtils.unescapeJava(s);
243
        if ( StringUtils.isBlank(s) ) {
244
            return null;
245
        }
246
        return s;
247
    }
248

  
249
    static String[] getHeaders(DynObject dynobj) {
250
        String s = getHeader(dynobj);
251
        if ( StringUtils.isBlank(s) ) {
252
            return null;
253
        }
254
        String sep = getDelimiter(s);
255
        if ( sep == null ) {
256
            // Chungo
257
            return null;
258
        }
259
        String[] ss = s.split("[" + sep + "]");
260
        return ss;
261
    }
262

  
263
    static boolean getAutomaticTypesDetection(DynObject dynobj) {
264
        Boolean b = (Boolean) dynobj.getDynValue(AUTOMATICTYPESDETECTION);
265
        if ( b == null ) {
266
            return false;
267
        }
268
        return b.booleanValue();
269
    }
270

  
271
    static boolean isFirstRowHeader(DynObject dynobj) {
272
        Boolean b = (Boolean) dynobj.getDynValue(ISFIRSTROWHEADER);
273
        if ( b == null ) {
274
            return false;
275
        }
276
        return b.booleanValue();
277
    }
278

  
279
}
org.gvsig.jexcel/tags/org.gvsig.jexcel-1.0.238/org.gvsig.jexcel.provider/src/main/java/org/gvsig/jexcel/dal/provider/JExcelFilesystemServerProvider.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.jexcel.dal.provider;
25

  
26
import java.io.File;
27

  
28
import org.gvsig.fmap.dal.DALLocator;
29
import org.gvsig.fmap.dal.DataManager;
30
import org.gvsig.fmap.dal.DataServerExplorer;
31
import org.gvsig.fmap.dal.DataStoreParameters;
32
import org.gvsig.fmap.dal.NewDataStoreParameters;
33
import org.gvsig.fmap.dal.exception.CreateException;
34
import org.gvsig.fmap.dal.exception.DataException;
35
import org.gvsig.fmap.dal.exception.FileNotFoundException;
36
import org.gvsig.fmap.dal.exception.RemoveException;
37
import org.gvsig.fmap.dal.resource.spi.ResourceConsumer;
38
import org.gvsig.fmap.dal.resource.spi.ResourceProvider;
39
import org.gvsig.fmap.dal.serverexplorer.filesystem.impl.AbstractFilesystemServerExplorerProvider;
40
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProvider;
41
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProviderServices;
42

  
43
public class JExcelFilesystemServerProvider extends AbstractFilesystemServerExplorerProvider 
44
	implements FilesystemServerExplorerProvider, ResourceConsumer {
45

  
46
	private FilesystemServerExplorerProviderServices serverExplorer;
47

  
48
	public String getDataStoreProviderName() {
49
		return JExcelStoreProvider.NAME;
50
	}
51

  
52
	public int getMode() {
53
		return DataServerExplorer.MODE_FEATURE | DataServerExplorer.MODE_GEOMETRY;
54
	}
55

  
56
	public boolean accept(File pathname) {
57
		return (pathname.getName().toLowerCase().endsWith(".xls"));
58
	}
59

  
60
	public String getDescription() {
61
		return JExcelStoreProvider.DESCRIPTION;
62
	}
63

  
64
	public DataStoreParameters getParameters(File file) throws DataException {
65
		DataManager manager = DALLocator.getDataManager();
66
		JExcelStoreParameters params = (JExcelStoreParameters) manager
67
				.createStoreParameters(this
68
				.getDataStoreProviderName());
69
		params.setFile(file);
70
		return params;
71
	}
72

  
73
	public boolean canCreate() {
74
		return false;
75
	}
76

  
77
	public boolean canCreate(NewDataStoreParameters parameters) {
78
			throw new UnsupportedOperationException(); 
79
	}
80

  
81
	public void create(NewDataStoreParameters parameters, boolean overwrite)
82
			throws CreateException {
83
		throw new UnsupportedOperationException(); 
84
	}
85

  
86
	public NewDataStoreParameters getCreateParameters() throws DataException {
87
		throw new UnsupportedOperationException(); 
88
	}
89

  
90
	public void initialize(
91
			FilesystemServerExplorerProviderServices serverExplorer) {
92
		this.serverExplorer = serverExplorer;
93
	}
94

  
95
	public void remove(DataStoreParameters parameters) throws RemoveException {
96
		File file = ((JExcelStoreParameters) parameters).getFile();
97
		if (!file.exists()) {
98
			throw new RemoveException(this.getDataStoreProviderName(),
99
					new FileNotFoundException(file));
100
		}
101
		if (!file.delete()) {
102
			// FIXME throws ???
103
		}
104

  
105
	}
106

  
107
	public boolean closeResourceRequested(ResourceProvider resource) {
108
		// while it is using a resource anyone can't close it
109
		return false;
110
	}
111

  
112
	public void resourceChanged(ResourceProvider resource) {
113
		//Do nothing
114

  
115
	}
116

  
117

  
118
}
org.gvsig.jexcel/tags/org.gvsig.jexcel-1.0.238/org.gvsig.jexcel.provider/src/main/java/org/gvsig/jexcel/dal/provider/JExcelStoreProvider.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA 02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.jexcel.dal.provider;
25

  
26
import java.io.File;
27
import java.io.IOException;
28
import java.text.SimpleDateFormat;
29
import java.util.ArrayList;
30
import java.util.HashMap;
31
import java.util.Iterator;
32
import java.util.List;
33
import java.util.Locale;
34
import javax.json.JsonObject;
35
import jxl.Cell;
36
import jxl.Sheet;
37
import jxl.Workbook;
38
import jxl.read.biff.BiffException;
39

  
40
import org.apache.commons.io.FilenameUtils;
41
import org.apache.commons.lang3.StringUtils;
42
import org.cresques.cts.IProjection;
43
import org.gvsig.fmap.dal.DALLocator;
44
import org.gvsig.fmap.dal.DataManager;
45
import org.gvsig.fmap.dal.DataServerExplorer;
46
import org.gvsig.fmap.dal.DataStore;
47
import org.gvsig.fmap.dal.DataStoreNotification;
48
import org.gvsig.fmap.dal.DataTypes;
49
import org.gvsig.fmap.dal.FileHelper;
50
import org.gvsig.fmap.dal.exception.DataException;
51
import org.gvsig.fmap.dal.exception.InitializeException;
52
import org.gvsig.fmap.dal.exception.OpenException;
53
import org.gvsig.fmap.dal.exception.ReadException;
54
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
55
import org.gvsig.fmap.dal.feature.EditableFeature;
56
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor;
57
import org.gvsig.fmap.dal.feature.EditableFeatureType;
58
import org.gvsig.fmap.dal.feature.Feature;
59
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
60
import org.gvsig.fmap.dal.feature.FeatureAttributeEmulator;
61
import org.gvsig.fmap.dal.feature.FeatureStore;
62
import org.gvsig.fmap.dal.feature.FeatureType;
63
import org.gvsig.fmap.dal.feature.exception.PerformEditingException;
64
import org.gvsig.fmap.dal.feature.spi.FeatureProvider;
65
import org.gvsig.fmap.dal.feature.spi.FeatureStoreProviderServices;
66
import org.gvsig.fmap.dal.feature.spi.memory.AbstractMemoryStoreProvider;
67
import org.gvsig.fmap.dal.resource.file.FileResource;
68
import org.gvsig.fmap.dal.resource.spi.ResourceConsumer;
69
import org.gvsig.fmap.dal.resource.spi.ResourceProvider;
70
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer;
71
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorerParameters;
72
import org.gvsig.fmap.dal.spi.DataStoreProviderServices;
73
import org.gvsig.fmap.geom.Geometry;
74
import org.gvsig.fmap.geom.GeometryLocator;
75
import org.gvsig.fmap.geom.GeometryManager;
76
import org.gvsig.fmap.geom.aggregate.MultiPoint;
77
import org.gvsig.fmap.geom.primitive.Envelope;
78
import org.gvsig.fmap.geom.primitive.Point;
79
import org.gvsig.fmap.geom.type.GeometryType;
80
import org.gvsig.json.Json;
81
import org.gvsig.json.JsonObjectBuilder;
82
import org.gvsig.tools.ToolsLocator;
83
import org.gvsig.tools.dataTypes.Coercion;
84
import org.gvsig.tools.dataTypes.CoercionException;
85
import org.gvsig.tools.dataTypes.DataType;
86
import org.gvsig.tools.dataTypes.DataTypesManager;
87
import org.gvsig.tools.dynobject.exception.DynFieldNotFoundException;
88
import org.gvsig.tools.exception.BaseException;
89
import org.gvsig.tools.exception.NotYetImplemented;
90
import org.gvsig.tools.logger.FilteredLogger;
91
import org.gvsig.tools.persistence.PersistentState;
92
import org.gvsig.tools.persistence.exception.PersistenceException;
93
import org.gvsig.tools.task.SimpleTaskStatus;
94
import org.gvsig.tools.task.TaskStatusManager;
95
import org.gvsig.tools.visitor.VisitCanceledException;
96
import org.gvsig.tools.visitor.Visitor;
97
import org.slf4j.Logger;
98
import org.slf4j.LoggerFactory;
99

  
100
@SuppressWarnings("UseSpecificCatch")
101
public class JExcelStoreProvider extends AbstractMemoryStoreProvider implements
102
        ResourceConsumer {
103

  
104
    private static final Logger logger = LoggerFactory.getLogger(JExcelStoreProvider.class);
105

  
106
    public static final String NAME = "JExcel";
107
    public static final String DESCRIPTION = "JExcel file";
108

  
109
    public static final String METADATA_DEFINITION_NAME = NAME;
110

  
111
    private ResourceProvider resource;
112

  
113
    private long counterNewsOIDs = 0;
114
    private Envelope envelope;
115
    private boolean need_calculate_envelope = false;
116
    private SimpleTaskStatus taskStatus;
117
    private String sheetName = "";
118

  
119
    public JExcelStoreProvider(JExcelStoreParameters parameters,
120
            DataStoreProviderServices storeServices) throws InitializeException {
121
        super(
122
                parameters,
123
                storeServices,
124
                FileHelper.newMetadataContainer(METADATA_DEFINITION_NAME)
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff