Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
cfsimplicity committed Sep 29, 2023
2 parents c933c6a + c6f9dd4 commit 22ca58e
Show file tree
Hide file tree
Showing 30 changed files with 117 additions and 28 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## 3.10.0 - 29 September 2023

- Maintenance
- \#334 Upgrade POI to 5.2.4 and excel-streaming-reader to 4.1.2
- \#324 Upgrade Commons CSV to 1.10.0

- Enhancements
- \#331 Allow custom date formats to be set on an instance post-init()
- \#328 Improve exception message when setRowHeight() is used with a non-existent row

## 3.9.0 - 2 May 2023

- Enhancements
Expand Down
2 changes: 1 addition & 1 deletion ModuleConfig.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ component{
this.author = "Julian Halliwell";
this.webURL = "https://github.com/cfsimplicity/spreadsheet-cfml";
this.description = "CFML Spreadsheet Library";
this.version = "3.9.0";
this.version = "3.10.0";
this.autoMapModels = false;

function configure(){
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ You may wish to place the spreadsheet library files in a central location with a
* [newXls](https://github.com/cfsimplicity/spreadsheet-cfml/wiki/newXls)
* [newXlsx](https://github.com/cfsimplicity/spreadsheet-cfml/wiki/newXlsx)
* [queryToCsv](https://github.com/cfsimplicity/spreadsheet-cfml/wiki/queryToCsv)
* [setDateFormats](https://github.com/cfsimplicity/spreadsheet-cfml/wiki/setDateFormats)
* [workbookFromCsv](https://github.com/cfsimplicity/spreadsheet-cfml/wiki/workbookFromCsv)
* [workbookFromQuery](https://github.com/cfsimplicity/spreadsheet-cfml/wiki/workbookFromQuery)
* [writeFileFromQuery](https://github.com/cfsimplicity/spreadsheet-cfml/wiki/writeFileFromQuery)
Expand Down Expand Up @@ -234,7 +235,14 @@ NB: _Do not confuse `DATETIME` and `TIMESTAMP`._ In general you should override
Each of these can be overridden by passing in a struct including the value(s) to be overridden when instantiating the Spreadsheet component. For example:
```
<cfscript>
spreadsheet = New spreadsheetLibrary.spreadsheet( dateFormats={ DATE: "mm/dd/yyyy" } );
spreadsheet = New spreadsheetLibrary.Spreadsheet( dateFormats={ DATE: "mm/dd/yyyy" } );
</cfscript>
```
Or by using the `setDateFormats()` method on an existing instance.
```
<cfscript>
spreadsheet = New spreadsheetLibrary.Spreadsheet();
spreadsheet.setDateFormats( { DATE: "mm/dd/yyyy" } );
</cfscript>
```
While the above will set the library defaults, you can format cells with specific masks using the `dataFormat` attribute which can be passed to [formatCell](https://github.com/cfsimplicity/spreadsheet-cfml/wiki/formatCell) and the other [formatting](https://github.com/cfsimplicity/spreadsheet-cfml/wiki/Formatting-options) methods, as part of the `format` argument:
Expand Down
18 changes: 13 additions & 5 deletions Spreadsheet.cfc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
component accessors="true"{

//"static"
property name="version" default="3.9.0" setter="false";
property name="osgiLibBundleVersion" default="5.2.3.3" setter="false"; //first 3 octets = POI version; increment 4th with other jar updates
property name="version" default="3.10.0" setter="false";
property name="osgiLibBundleVersion" default="5.2.4.0" setter="false"; //first 3 octets = POI version; increment 4th with other jar updates
property name="osgiLibBundleSymbolicName" default="spreadsheet-cfml" setter="false";
property name="exceptionType" default="cfsimplicity.spreadsheet" setter="false";
//configurable
Expand Down Expand Up @@ -40,12 +40,12 @@ component accessors="true"{
property name="stringHelper" setter="false";
property name="workbookHelper" setter="false";

public function init( struct dateFormats, string javaLoaderDotPath, boolean requiresJavaLoader ){
public Spreadsheet function init( struct dateFormats, string javaLoaderDotPath, boolean requiresJavaLoader ){
detectEngineProperties();
loadHelpers();
variables.dateFormats = getDateHelper().defaultFormats();
if( arguments.KeyExists( "dateFormats" ) )
getDateHelper().setCustomFormats( arguments.dateFormats );
setDateFormats( arguments.dateFormats );
variables.requiresJavaLoader = this.getIsACF() || ( arguments.KeyExists( "requiresJavaLoader" ) && arguments.requiresJavaLoader );
if( !this.getRequiresJavaLoader() ){
variables.osgiLoader = New osgiLoader();
Expand Down Expand Up @@ -1419,6 +1419,11 @@ component accessors="true"{
return this;
}

public Spreadsheet function setDateFormats( required struct dateFormats ){
getDateHelper().setCustomFormats( arguments.dateFormats );
return this;
}

public Spreadsheet function setFitToPage( required workbook, required boolean state, numeric pagesWide, numeric pagesHigh ){
var sheet = getSheetHelper().getActiveSheet( arguments.workbook );
sheet.setFitToPage( JavaCast( "boolean", arguments.state ) );
Expand Down Expand Up @@ -1516,7 +1521,10 @@ component accessors="true"{
}

public Spreadsheet function setRowHeight( required workbook, required numeric row, required numeric height ){
getRowHelper().getRowFromActiveSheet( arguments.workbook, arguments.row ).setHeightInPoints( JavaCast( "int", arguments.height ) );
var rowObject = getRowHelper().getRowFromActiveSheet( arguments.workbook, arguments.row );
if( IsNull( rowObject ) )
getExceptionHelper().throwNonExistentRowException( arguments.row );
rowObject.setHeightInPoints( JavaCast( "int", arguments.height ) );
return this;
}

Expand Down
2 changes: 1 addition & 1 deletion box.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name" : "Spreadsheet CFML",
"slug" : "spreadsheet-cfml",
"version" : "3.9.0",
"version" : "3.10.0",
"shortDescription" : "CFML spreadsheet library",
"author" : "Julian Halliwell",
"location" : "forgeboxStorage",
Expand Down
34 changes: 30 additions & 4 deletions build/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,36 @@ Whenever either the java in `/src` or the jars in `/lib` change, the `lib-osgi.j
```
task run
```
## Note on `poi-ooxml` jars
## POI binaries

The POI binary distribution includes two jar files:
From version 5.2.4 a binary distribution (zip) is no longer provided. This means the POI, POI OOXML and POI OOXML-FULL jars need to be downloaded individually from

`poi-ooxml-lite-VERSION.jar` and `poi-ooxml-full-VERSION.jar`
https://repo1.maven.org/maven2/org/apache/poi/

Only the *full* version is needed. Delete the lite version if copied to `/lib`
Dependencies and versions are given in the .pom files in the /poi, /poi-ooxml and /poi-ooxml-full directories. These jars can be downloaded by searching:

https://mvnrepository.com

Here is the current list of required jars:

* commons-codec
* commons-collections4
* commons-compress
* commons-io
* commons-math3
* log4j-api
* poi
* poi-ooxml
* poi-ooxml-full
* SparseBitSet
* xmlbeans

## Other dependency binaries

The following jars are not POI dependencies but are required by the Spreadsheet Library:

* commons-csv
* excel-streaming-reader
* slf4j-api

All available from https://mvnrepository.com
22 changes: 11 additions & 11 deletions build/lib-osgi.mf
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Spreadsheet CFML
Bundle-SymbolicName: spreadsheet-cfml
Bundle-Version: 5.2.3.3
Bundle-ClassPath: commons-codec-1.15.jar,
Bundle-Version: 5.2.4.0
Bundle-ClassPath: commons-codec-1.16.0.jar,
commons-collections4-4.4.jar,
commons-compress-1.21.jar,
commons-csv-1.9.0.jar,
commons-io-2.11.0.jar,
commons-compress-1.24.0.jar,
commons-csv-1.10.0.jar,
commons-io-2.13.0.jar,
commons-math3-3.6.1.jar,
excel-streaming-reader-4.0.5.jar,
log4j-api-2.18.0.jar,
poi-5.2.3.jar,
poi-ooxml-5.2.3.jar,
poi-ooxml-full-5.2.3.jar,
excel-streaming-reader-4.1.2.jar,
log4j-api-2.20.0.jar,
poi-5.2.4.jar,
poi-ooxml-5.2.4.jar,
poi-ooxml-full-5.2.4.jar,
slf4j-api-1.7.36.jar,
SparseBitSet-1.2.jar,
SparseBitSet-1.3.jar,
spreadsheet-cfml.jar,
xmlbeans-5.1.1.jar
2 changes: 1 addition & 1 deletion build/task.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ component{
property name="classpathDirectories";
property name="libPath";
property name="minimumSupportedJvmVersion" default="8";//update this as necessary
property name="ooxmlVersion" default="5.2.3";
property name="ooxmlVersion" default="5.2.4";
property name="rootPath";
property name="srcPath";
property name="tempDirectoryPath";
Expand Down
4 changes: 4 additions & 0 deletions helpers/exception.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,8 @@ component extends="base"{
Throw( type=library().getExceptionType() & ".invalidSpreadsheetType", message="Invalid spreadsheet file", detail="readLargeFile() can only be used with XLSX files. The file you are trying to read does not appear to be an XLSX file." );
}

void function throwNonExistentRowException( required numeric rowNumber ){
Throw( type=library().getExceptionType() & ".nonExistentRow", message="Non-existent row", detail="Row #arguments.rowNumber# doesn't exist. You may need to create the row first by adding data to it." );
}

}
Binary file modified lib-osgi.jar
Binary file not shown.
Binary file removed lib/SparseBitSet-1.2.jar
Binary file not shown.
Binary file added lib/SparseBitSet-1.3.jar
Binary file not shown.
Binary file removed lib/commons-codec-1.15.jar
Binary file not shown.
Binary file added lib/commons-codec-1.16.0.jar
Binary file not shown.
Binary file removed lib/commons-compress-1.21.jar
Binary file not shown.
Binary file added lib/commons-compress-1.24.0.jar
Binary file not shown.
Binary file added lib/commons-csv-1.10.0.jar
Binary file not shown.
Binary file removed lib/commons-csv-1.9.0.jar
Binary file not shown.
Binary file removed lib/commons-io-2.11.0.jar
Binary file not shown.
Binary file added lib/commons-io-2.13.0.jar
Binary file not shown.
Binary file removed lib/excel-streaming-reader-4.0.5.jar
Binary file not shown.
Binary file added lib/excel-streaming-reader-4.1.2.jar
Binary file not shown.
Binary file removed lib/log4j-api-2.18.0.jar
Binary file not shown.
Binary file added lib/log4j-api-2.20.0.jar
Binary file not shown.
Binary file renamed lib/poi-5.2.3.jar → lib/poi-5.2.4.jar
Binary file not shown.
Binary file renamed lib/poi-ooxml-5.2.3.jar → lib/poi-ooxml-5.2.4.jar
Binary file not shown.
Binary file not shown.
Binary file modified lib/spreadsheet-cfml.jar
Binary file not shown.
29 changes: 25 additions & 4 deletions test/specs/dateFormats.cfm
Original file line number Diff line number Diff line change
@@ -1,27 +1,48 @@
<cfscript>
describe( "dateFormats customisability",function(){
it( "the default dateFormats can be overridden individually",function() {
it( "the default dateFormats can be overridden individually on init", function() {
local.s = newSpreadsheetInstance();
var expected = {
DATE: "yyyy-mm-dd"
,DATETIME: "yyyy-mm-dd HH:nn:ss"
,TIME: "hh:mm:ss"
,TIMESTAMP: "yyyy-mm-dd hh:mm:ss"
};
var actual = s.getDateFormats();
var actual = local.s.getDateFormats();
expect( actual ).toBe( expected );
local.s = newSpreadsheetInstance( dateFormats={ DATE="mm/dd/yyyy" } );
local.s = newSpreadsheetInstance( dateFormats={ DATE: "mm/dd/yyyy" } );
expected = {
DATE: "mm/dd/yyyy"
,DATETIME: "yyyy-mm-dd HH:nn:ss"
,TIME: "hh:mm:ss"
,TIMESTAMP: "yyyy-mm-dd hh:mm:ss"
};
actual = s.getDateFormats();
actual = local.s.getDateFormats();
expect( actual ).toBe( expected );
});
it( "the dateFormats can be set post-init", function() {
local.s = newSpreadsheetInstance();
var expected = {
DATE: "yyyy-mm-dd"
,DATETIME: "yyyy-mm-dd HH:nn:ss"
,TIME: "hh:mm:ss"
,TIMESTAMP: "yyyy-mm-dd hh:mm:ss"
};
var actual = local.s.getDateFormats();
expect( actual ).toBe( expected );
var customDateFormats = { DATE: "mm/dd/yyyy" };
local.s.setDateFormats( customDateFormats );
expected = {
DATE: "mm/dd/yyyy"
,DATETIME: "yyyy-mm-dd HH:nn:ss"
,TIME: "hh:mm:ss"
,TIMESTAMP: "yyyy-mm-dd hh:mm:ss"
};
expect( local.s.getDateFormats() ).toBe( expected );
});
it( "allows the format of date and time values to be customised", function() {
variables.workbooks = [ s.newXls(), s.newXlsx() ];
//Dates
Expand Down
12 changes: 12 additions & 0 deletions test/specs/setRowHeight.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,17 @@ describe( "setRowHeight", function(){
});
});
describe( "setRowHeight throws an exception if", function(){
it( "the specified row doesn't exist", function(){
workbooks.Each( function( wb ){
expect( function(){
s.setRowHeight( wb, 10, newHeight );
}).toThrow( type="cfsimplicity.spreadsheet.nonExistentRow" );
});
});
});
});
</cfscript>

0 comments on commit 22ca58e

Please sign in to comment.