CoreXLSX icon indicating copy to clipboard operation
CoreXLSX copied to clipboard

Unable to parse excel with following code

Open manish12jain opened this issue 2 years ago • 5 comments

I am using main branch which i have installed using following pod

pod 'CoreXLSX'

I am trying to read one excel but its giving me random integer number instead of string.

Test12.xlsx

    func getExcelData(pathNew: URL) {
                
        let k: UInt32 = 10 * 1024 * 1024
        
        guard let file = try? XLSXFile(data: Data(contentsOf: pathNew), bufferSize: k, errorContextLength: 10) else {
            return }

        do {
            for wbk in try file.parseWorkbooks() {
                for (name, path) in try file.parseWorksheetPathsAndNames(workbook: wbk) {
                    if let worksheetName = name {
                        print("This worksheet has a name: \(worksheetName)")
                    }

                    
                    let worksheet = try file.parseWorksheet(at: path)
                    
                    let array = worksheet.data?.rows.map { $0.cells.map { $0.value ?? "" } }
                }
            }
        } catch {
            print(error)
        }
Screenshot 2022-04-15 at 8 46 01 PM

manish12jain avatar Apr 15 '22 15:04 manish12jain

Same here using func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL])

if I converted urls.first!.path it does not read the xlsx document

I tried the both

XLSXFile(filepath: ) XLSX(data: )

But it still does not read the file

tburnt avatar Jul 22 '22 08:07 tburnt

@tburnt please refer to #160 WRT document picker. Are you providing a security scoped access URL, as described in a solution for this issue? https://github.com/CoreOffice/CoreXLSX/issues/160

Also, your issue does not seem to be related to the OP. If your issue is not resolve with security scoped access URLs, please create a new issue. Thanks.

MaxDesiatov avatar Jul 22 '22 08:07 MaxDesiatov

Hello thanks for the fast response I tried #160 as well however I had no luck in opening the excel file

tburnt avatar Jul 22 '22 09:07 tburnt

Please create a separate issue and provide additional details there: the exact error message and error type you're seeing, the file you're trying to open, and a self-contained sample project to reproduce. Providing these details will allow me to quickly resolve the issue. Thanks!

MaxDesiatov avatar Jul 22 '22 09:07 MaxDesiatov

Because the cells refer shared string. Follow this guide - https://github.com/CoreOffice/CoreXLSX#shared-strings

GST-Main avatar Mar 24 '23 10:03 GST-Main