Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
cfsimplicity committed Aug 6, 2024
2 parents ad26130 + b15a88f commit 40e10b0
Show file tree
Hide file tree
Showing 12 changed files with 57 additions and 11 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## 4.2.0 - 6 August 2024

- Enhancements
- \#373 Allow datatype to be specified with addColumn()
- \#374 Rename setCellValue() "type" argument to "datatype" for consistency

- Maintenance
-\#375 Upgrade excel-streaming-reader to 5.0.2

## 4.1.1 - 9 July 2024

- Maintenance
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 = "4.1.1";
this.version = "4.2.0";
this.autoMapModels = false;

function configure(){
Expand Down
20 changes: 15 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="4.1.1" setter="false";
property name="osgiLibBundleVersion" default="5.3.0.0" setter="false"; //first 3 octets = POI version; increment 4th with other jar updates
property name="version" default="4.2.0" setter="false";
property name="osgiLibBundleVersion" default="5.3.0.1" 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 @@ -201,6 +201,7 @@ component accessors="true"{
,boolean insert=false
,string delimiter=","
,boolean autoSize=false
,string datatype
){
var sheet = getSheetHelper().getActiveSheet( arguments.workbook );
var rowIndex = arguments.KeyExists( "startRow" )? ( arguments.startRow -1 ): 0;
Expand All @@ -216,8 +217,14 @@ component accessors="true"{
var insertRequired = ( arguments.KeyExists( "startColumn" ) && arguments.insert && ( columnIndex < row.getLastCellNum() ) );
if( insertRequired )
getColumnHelper().shiftColumnsRightStartingAt( columnIndex, row, arguments.workbook );
var cell = getCellHelper().createCell( row, columnIndex );
getCellHelper().setCellValueAsType( arguments.workbook, cell, cellValue );
var cellValueArgs = {
workbook: arguments.workbook
,cell: getCellHelper().createCell( row, columnIndex )
,value: cellValue
};
if( arguments.KeyExists( "datatype" ) )
cellValueArgs.type = arguments.datatype;
getCellHelper().setCellValueAsType( argumentCollection=cellValueArgs );
rowIndex++;
}
if( arguments.autoSize )
Expand Down Expand Up @@ -1428,12 +1435,15 @@ component accessors="true"{
return this;
}

public Spreadsheet function setCellValue( required workbook, required value, required numeric row, required numeric column, string type ){
public Spreadsheet function setCellValue( required workbook, required value, required numeric row, required numeric column, string datatype ){
var args = {
workbook: arguments.workbook
,cell: getCellHelper().initializeCell( arguments.workbook, arguments.row, arguments.column )
,value: arguments.value
};
if( arguments.KeyExists( "datatype" ) )
args.type = arguments.datatype;
//support legacy argument name
if( arguments.KeyExists( "type" ) )
args.type = arguments.type;
getCellHelper().setCellValueAsType( argumentCollection=args );
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" : "4.1.1",
"version" : "4.2.0",
"shortDescription" : "CFML spreadsheet library",
"author" : "Julian Halliwell",
"location" : "forgeboxStorage",
Expand Down
4 changes: 2 additions & 2 deletions build/lib-osgi.mf
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Spreadsheet CFML
Bundle-SymbolicName: spreadsheet-cfml
Bundle-Version: 5.3.0.0
Bundle-Version: 5.3.0.1
Bundle-ClassPath: commons-codec-1.17.0.jar,
commons-collections4-4.4.jar,
commons-compress-1.26.2.jar,
commons-csv-1.11.0.jar,
commons-io-2.16.1.jar,
commons-math3-3.6.1.jar,
excel-streaming-reader-4.4.0.jar,
excel-streaming-reader-5.0.2.jar,
log4j-api-2.23.1.jar,
poi-5.3.0.jar,
poi-ooxml-5.3.0.jar,
Expand Down
Binary file modified lib-osgi.jar
Binary file not shown.
Binary file removed lib/excel-streaming-reader-4.4.0.jar
Binary file not shown.
Binary file added lib/excel-streaming-reader-5.0.2.jar
Binary file not shown.
Binary file modified lib/spreadsheet-cfml.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion objects/SpreadsheetChainable.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ component{
return this;
}

public SpreadsheetChainable function setCellValue( required value, required numeric row, required numeric column, string type ){
public SpreadsheetChainable function setCellValue( required value, required numeric row, required numeric column, string datatype ){
addWorkbookArgument( arguments );
variables.library.setCellValue( argumentCollection=arguments );
return this;
Expand Down
12 changes: 11 additions & 1 deletion test/specs/addColumn.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,22 @@ describe( "addColumn", function(){
it( "Adds a column including commas with a custom delimiter", function(){
workbooks.Each( function( wb ){
var columnData = "a,b|c,d";
s.addColumn( workbook=wb, data=columnData,delimiter="|" );
s.addColumn( workbook=wb, data=columnData, delimiter="|" );
var expected = QueryNew( "column1", "VarChar", [ [ "a,b" ], [ "c,d" ] ] );
var actual = s.getSheetHelper().sheetToQuery( wb );
expect( actual ).toBe( expected );
});
});
it( "Allows the data type to be specified", function(){
var columnData = [ 1.234 ];
workbooks.Each( function( wb ){
s.addColumn( workbook=wb, data=columnData, datatype="string" );
var actual = s.getCellValue( wb, 1, 1 );
expect( actual ).toBe( "1.234" );
expect( s.getCellType( wb, 1, 1 ) ).toBe( "string" );
});
});
describe( "Insert behaviour", function(){
Expand Down
17 changes: 17 additions & 0 deletions test/specs/cellValue.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,23 @@ describe( "cellValue", function(){
});
});
it( "support legacy 'type' argument name", function(){
var value = 1.234;
workbooks.Each( function( wb ){
s.setCellValue( workbook=wb, value=value, row=1, column=1, type="string" );
var actual = s.getCellValue( wb, 1, 1 );
expect( actual ).toBe( "1.234" );
expect( s.getCellType( wb, 1, 1 ) ).toBe( "string" );
});
workbooks.Each( function( wb ){
var actual = s.newChainable( wb )
.setCellValue( value=value, row=1, column=1, type="string" )
.getCellValue( 1, 1 );
expect( actual ).toBe( "1.234" );
expect( s.getCellType( wb, 1, 1 ) ).toBe( "string" );
});
});
});
describe(
Expand Down

0 comments on commit 40e10b0

Please sign in to comment.