cfsimplicity / spreadsheet-cfml

Standalone library for working with spreadsheets and CSV in CFML
MIT License
126 stars 35 forks source link

Can't import spreadsheet #284

Closed Daemach closed 2 years ago

Daemach commented 2 years ago

I'm trying to import the attached spreadsheet and it's failing for some reason. Often, if I inspect a spreadsheet and remove all extraneous data, it starts working (it would be great if this wasn't necessary). This time it's not working. Can you take a look?

  function importSpreadSheet( path, header = true, tab ) {
    var tabName = arguments.tab;
    switch ( listLast( path, "." ) ) {
      case "xls":
      case "xlsx":
        var args = { src : path, format : "query" }
        if ( arguments.header ) {
          args.headerRow = 1
        }
        if ( !isNull( arguments.tab ) ) {
          var info       = spreadsheet.info( path )
          args.sheetName = listToArray( info.sheetnames ).filter( ( e ) => e contains tabName )[ 1 ]
        }
        return spreadsheet.read( argumentcollection = args );
        break;
      case "csv":
        return spreadsheet.csvToQuery( filepath = path, firstRowIsHeader = header );
        break;
    }
  }

Holdings_Template_allValidXLSX.xlsx

cfsimplicity commented 2 years ago

Calling your function with

path = ExpandPath( "Holdings_Template_allValidXLSX.xlsx" )
dump( importSpreadSheet( path ) )

seems to work fine for me on Lucee 5.3.8.206

Screenshot 2022-02-28 at 18-14-28 https test

How is it failing for you?

Daemach commented 2 years ago

I think something was wrong with the server. It worked locally, I updated the libraries, restarted the services and it's working now. Sorry to waste your time on this.

The extra info thing is still a problem, though. Unfortunately, I don't have an example sheet to send you. I'll open another case when I get one.