Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
cfsimplicity committed Jan 15, 2022
2 parents f4aff65 + 57b5a1f commit e9b5384
Show file tree
Hide file tree
Showing 37 changed files with 255 additions and 228 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 3.3.0

- \#282 Upgrade POI to 5.2.0

## 3.2.5 - 30 December 2021

- Security Update
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015-2021 Julian Halliwell
Copyright (c) 2015-2022 Julian Halliwell

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
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.2.5";
this.version = "3.3.0";
this.autoMapModels = false;

function configure(){
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ The code was originally adapted from the work of [TeamCfAdvance](https://github.

### The MIT License (MIT)

Copyright (c) 2015-2021 Julian Halliwell
Copyright (c) 2015-2022 Julian Halliwell

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
Expand Down
88 changes: 39 additions & 49 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.2.5" setter="false";
property name="osgiLibBundleVersion" default="5.1.0.4" setter="false"; //first 3 octets = POI version; increment 4th with other jar updates
property name="version" default="3.3.0" setter="false";
property name="osgiLibBundleVersion" default="5.2.0.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";
//commonly invoked POI class names
Expand Down Expand Up @@ -193,52 +193,29 @@ component accessors="true"{
Throw( type=this.getExceptionType(), message="Missing required argument", detail="Please provide either a csv string (csv), or the path of a file containing one (filepath)." );
if( csvIsString && csvIsFile )
Throw( type=this.getExceptionType(), message="Mutually exclusive arguments: 'csv' and 'filepath'", detail="Only one of either 'filepath' or 'csv' arguments may be provided." );
if( csvIsFile ){
getFileHelper()
.throwErrorIFfileNotExists( arguments.filepath )
.throwErrorIFnotCsvOrTextFile( arguments.filepath );
arguments.csv = FileRead( arguments.filepath );
}
var csvString = csvIsFile? getCsvHelper().readFile( arguments.filepath ): arguments.csv;
if( IsStruct( arguments.queryColumnTypes ) && !arguments.firstRowIsHeader && !arguments.KeyExists( "queryColumnNames" ) )
Throw( type=this.getExceptionType(), message="Invalid argument 'queryColumnTypes'.", detail="When specifying 'queryColumnTypes' as a struct you must also set the 'firstRowIsHeader' argument to true OR provide 'queryColumnNames'" );
if( arguments.trim )
arguments.csv = arguments.csv.Trim();
csvString = csvString.Trim();
var format = arguments.KeyExists( "delimiter" )?
getCsvHelper().getCsvFormatForDelimiter( arguments.delimiter )
: getClassHelper().loadClass( "org.apache.commons.csv.CSVFormat" )[ JavaCast( "string", "RFC4180" ) ].withIgnoreSurroundingSpaces();
var parsed = getClassHelper().loadClass( "org.apache.commons.csv.CSVParser" ).parse( arguments.csv, format );
var parsed = getClassHelper().loadClass( "org.apache.commons.csv.CSVParser" ).parse( csvString, format );
var records = parsed.getRecords();
var data = [];
var maxColumnCount = 0;
for( var record in records ){
var row = [];
var columnNumber = 0;
var iterator = record.iterator();
while( iterator.hasNext() ){
columnNumber++;
maxColumnCount = Max( maxColumnCount, columnNumber );
row.Append( iterator.next() );
}
data.Append( row );
}
if( arguments.KeyExists( "queryColumnNames" ) && arguments.queryColumnNames.Len() )
var dataFromRecords = getCsvHelper().dataFromRecords( records );
var data = dataFromRecords.data;
var maxColumnCount = dataFromRecords.maxColumnCount;
if( arguments.KeyExists( "queryColumnNames" ) && arguments.queryColumnNames.Len() ){
var columnNames = arguments.queryColumnNames;
else{
var columnNames = [];
if( arguments.firstRowIsHeader )
var headerRow = data[ 1 ];
for( var i=1; i <= maxColumnCount; i++ ){
if( arguments.firstRowIsHeader && !IsNull( headerRow[ i ] ) && headerRow[ i ].Len() ){
columnNames.Append( headerRow[ i ] );
continue;
}
columnNames.Append( "column#i#" );
}
if( arguments.firstRowIsHeader )
data.DeleteAt( 1 );
var parsedQueryColumnTypes = getQueryHelper().parseQueryColumnTypesArgument( arguments.queryColumnTypes, columnNames, maxColumnCount, data );
return getQueryHelper()._QueryNew( columnNames, parsedQueryColumnTypes, data, arguments.makeColumnNamesSafe );
}
arguments.queryColumnTypes = getQueryHelper().parseQueryColumnTypesArgument( arguments.queryColumnTypes, columnNames, maxColumnCount, data );
return getQueryHelper()._QueryNew( columnNames, arguments.queryColumnTypes, data, arguments.makeColumnNamesSafe );
var columnNames = getCsvHelper().getColumnNames( arguments.firstRowIsHeader, data, maxColumnCount );
if( arguments.firstRowIsHeader )
data.DeleteAt( 1 );
var parsedQueryColumnTypes = getQueryHelper().parseQueryColumnTypesArgument( arguments.queryColumnTypes, columnNames, maxColumnCount, data );
return getQueryHelper()._QueryNew( columnNames, parsedQueryColumnTypes, data, arguments.makeColumnNamesSafe );
}

public void function download( required workbook, required string filename, string contentType ){
Expand Down Expand Up @@ -412,7 +389,13 @@ component accessors="true"{
if( arguments.cellRange.IsEmpty() ){
//default to all columns in the first (default) or specified row
var rowIndex = ( Max( 0, arguments.row -1 ) );
var cellRangeAddress = getCellHelper().getCellRangeAddressFromColumnAndRowIndices( rowIndex, rowIndex, 0, ( getColumnCount( arguments.workbook ) -1 ) );
var indices = {
startRow: rowIndex
,endRow: rowIndex
,startColumn: 0
,endColumn: ( getColumnCount( arguments.workbook ) -1 )
};
var cellRangeAddress = getCellHelper().getCellRangeAddressFromColumnAndRowIndices( indices );
getSheetHelper().getActiveSheet( arguments.workbook ).setAutoFilter( cellRangeAddress );
return this;
}
Expand Down Expand Up @@ -772,9 +755,10 @@ component accessors="true"{
Throw( type=this.getExceptionType(), message="Invalid column value", detail="The value for column must be greater than or equal to 1." );
// POI doesn't have remove column functionality, so iterate over all the rows and remove the column indicated
var rowIterator = getSheetHelper().getActiveSheet( arguments.workbook ).rowIterator();
var columnIndex = ( arguments.column -1 );
while( rowIterator.hasNext() ){
var row = rowIterator.next();
var cell = row.getCell( JavaCast( "int", ( arguments.column -1 ) ) );
var cell = row.getCell( JavaCast( "int", columnIndex ) );
if( IsNull( cell ) )
continue;
row.removeCell( cell );
Expand Down Expand Up @@ -1216,12 +1200,13 @@ component accessors="true"{
Throw( type=this.getExceptionType(), message="Invalid startRow or endRow", detail="Row values must be greater than 0 and the startRow cannot be greater than the endRow." );
if( arguments.startColumn < 1 || arguments.startColumn > arguments.endColumn )
Throw( type=this.getExceptionType(), message="Invalid startColumn or endColumn", detail="Column values must be greater than 0 and the startColumn cannot be greater than the endColumn." );
var cellRangeAddress = getCellHelper().getCellRangeAddressFromColumnAndRowIndices(
( arguments.startRow - 1 )
,( arguments.endRow - 1 )
,( arguments.startColumn - 1 )
,( arguments.endColumn - 1 )
);
var indices = {
startRow: ( arguments.startRow - 1 )
,endRow: ( arguments.endRow - 1 )
,startColumn: ( arguments.startColumn - 1 )
,endColumn: ( arguments.endColumn - 1 )
};
var cellRangeAddress = getCellHelper().getCellRangeAddressFromColumnAndRowIndices( indices );
getSheetHelper().getActiveSheet( arguments.workbook ).addMergedRegion( cellRangeAddress );
if( !arguments.emptyInvisibleCells )
return this;
Expand All @@ -1242,7 +1227,11 @@ component accessors="true"{
){
if( arguments.streamingXml && !arguments.xmlFormat )
arguments.xmlFormat = true;
var workbook = getWorkbookHelper().createWorkBook( argumentCollection=arguments );
var createArgs.type = getWorkbookHelper().typeFromArguments( arguments.xmlFormat, arguments.streamingXml );
if( arguments.KeyExists( "streamingWindowSize" ) )
createArgs.streamingWindowSize = arguments.streamingWindowSize;
var workbook = getWorkbookHelper().createWorkBook( argumentCollection=createArgs );
getSheetHelper().validateSheetName( arguments.sheetName );
createSheet( workbook, arguments.sheetName, arguments.xmlFormat );
setActiveSheet( workbook, arguments.sheetName );
return workbook;
Expand Down Expand Up @@ -1463,7 +1452,8 @@ component accessors="true"{
*/
var factory = arguments.workbook.getCreationHelper();
var commentString = factory.createRichTextString( JavaCast( "string", arguments.comment.comment ) );
var anchor = getCommentHelper().createCommentAnchor( factory, arguments.comment, arguments.row, arguments.column );
var cellAddress = { row: arguments.row, column: arguments.column };
var anchor = getCommentHelper().createCommentAnchor( factory, arguments.comment, cellAddress );
var drawingPatriarch = getSheetHelper().getActiveSheet( arguments.workbook ).createDrawingPatriarch();
var commentObject = drawingPatriarch.createCellComment( anchor );
if( arguments.comment.KeyExists( "author" ) )
Expand Down
4 changes: 2 additions & 2 deletions box.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name" : "Spreadsheet CFML",
"slug" : "spreadsheet-cfml",
"version" : "3.2.5",
"version" : "3.3.0",
"shortDescription" : "CFML spreadsheet library",
"author" : "Julian Halliwell",
"location" : "https://github.com/cfsimplicity/spreadsheet-cfml/archive/v3.2.5.zip",
"location" : "https://github.com/cfsimplicity/spreadsheet-cfml/archive/v3.3.0.zip",
"homepage" : "https://github.com/cfsimplicity/spreadsheet-cfml",
"projectURL" : "https://github.com/cfsimplicity/spreadsheet-cfml",
"documentation" : "https://github.com/cfsimplicity/spreadsheet-cfml/blob/main/README.md",
Expand Down
10 changes: 5 additions & 5 deletions build/lib-osgi.mf
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Spreadsheet CFML
Bundle-SymbolicName: spreadsheet-cfml
Bundle-Version: 5.1.0.4
Bundle-Version: 5.2.0.0
Bundle-ClassPath: commons-codec-1.15.jar,
commons-collections4-4.4.jar,
commons-compress-1.21.jar,
commons-csv-1.9.0.jar,
commons-io-2.11.0.jar,
commons-math3-3.6.1.jar,
log4j-api-2.17.1.jar,
poi-5.1.0.jar,
poi-ooxml-5.1.0.jar,
poi-ooxml-full-5.1.0.jar,
poi-5.2.0.jar,
poi-ooxml-5.2.0.jar,
poi-ooxml-full-5.2.0.jar,
SparseBitSet-1.2.jar,
spreadsheet-cfml.jar,
xmlbeans-5.0.2.jar
xmlbeans-5.0.3.jar
4 changes: 2 additions & 2 deletions build/task.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ component{
variables.libPath = variables.rootPath & "lib/";
variables.classpathDirectories = [
variables.srcPath
,variables.libPath & "poi-ooxml-5.1.0.jar"
,variables.libPath & "xmlbeans-5.0.2.jar"
,variables.libPath & "poi-ooxml-5.2.0.jar"
,variables.libPath & "xmlbeans-5.0.3.jar"
];
var jarFileName = "spreadsheet-cfml.jar";
var classNames = [ "HeaderImageVML" ]; //allows for more source files in future
Expand Down
48 changes: 24 additions & 24 deletions helpers/base.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -3,101 +3,101 @@ component accessors="true"{
property name="libraryInstance";
property name="rootPath";

public any function init( required Spreadsheet libraryInstance ){
any function init( required Spreadsheet libraryInstance ){
this.setLibraryInstance( arguments.libraryInstance );
this.setRootPath( GetDirectoryFromPath( GetCurrentTemplatePath() ) & "../" );
return this;
}

public Spreadsheet function library(){
Spreadsheet function library(){
return this.getLibraryInstance();
}

public any function getCellHelper(){
any function getCellHelper(){
return library().getCellHelper();
}

public any function getClassHelper(){
any function getClassHelper(){
return library().getClassHelper();
}

public any function getColorHelper(){
any function getColorHelper(){
return library().getColorHelper();
}

public any function getColumnHelper(){
any function getColumnHelper(){
return library().getColumnHelper();
}

public any function getCommetHelper(){
any function getCommetHelper(){
return library().getCommetHelper();
}

public any function getCsvHelper(){
any function getCsvHelper(){
return library().getCsvHelper();
}

public any function getDataTypeHelper(){
any function getDataTypeHelper(){
return library().getDataTypeHelper();
}

public any function getDateHelper(){
any function getDateHelper(){
return library().getDateHelper();
}

public any function getExceptionHelper(){
any function getExceptionHelper(){
return library().getExceptionHelper();
}

public any function getFileHelper(){
any function getFileHelper(){
return library().getFileHelper();
}

public any function getFontHelper(){
any function getFontHelper(){
return library().getFontHelper();
}

public any function getFormatHelper(){
any function getFormatHelper(){
return library().getFormatHelper();
}

public any function getHeaderImageHelper(){
any function getHeaderImageHelper(){
return library().getHeaderImageHelper();
}

public any function getImageHelper(){
any function getImageHelper(){
return library().getImageHelper();
}

public any function getInfoHelper(){
any function getInfoHelper(){
return library().getInfoHelper();
}

public any function getQueryHelper(){
any function getQueryHelper(){
return library().getQueryHelper();
}

public any function getRangeHelper(){
any function getRangeHelper(){
return library().getRangeHelper();
}

public any function getRowHelper(){
any function getRowHelper(){
return library().getRowHelper();
}

public any function getSheetHelper(){
any function getSheetHelper(){
return library().getSheetHelper();
}

public any function getStringHelper(){
any function getStringHelper(){
return library().getStringHelper();
}

public any function getVisibilityHelper(){
any function getVisibilityHelper(){
return library().getvisibilityHelper();
}

public any function getWorkbookHelper(){
any function getWorkbookHelper(){
return library().getWorkbookHelper();
}

Expand Down
Loading

0 comments on commit e9b5384

Please sign in to comment.