Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cant parse file #47

Closed
murabye opened this issue Mar 18, 2019 · 2 comments
Closed

cant parse file #47

murabye opened this issue Mar 18, 2019 · 2 comments

Comments

@murabye
Copy link

murabye commented Mar 18, 2019

Maybe I use library incorrectly way, sorry.
I can't parse files from google sheets.
Example file is: https://docs.google.com/spreadsheets/d/1sYkVn4MkLaXS2zUrh3_HTsgHHqNvWy-47dhlh32EfqM/export?format=xlsx
I try to parse sheet from the file and get something about:
Cell(reference: C1, type: Optional("s"), s: Optional("2"), inlineString: nil, formula: nil, value: Optional("1"))
But there is string "АПО-1" in cell C1. I get values like strange numbers for each cell in the table.

Code is here:

guard let url = url, let file = XLSXFile(filepath: url.path) else { return }
for path in try file.parseWorksheetPaths() {
let ws = try file.parseWorksheet(at: path)
for row in ws.data?.rows ?? [] {
for c in row.cells {
print(c)
}
}
}

@murabye
Copy link
Author

murabye commented Mar 18, 2019

sorry, google sheets gives all cells like shared and I can read it by

let sharedStrings = try file.parseSharedStrings()
let columnCStrings = ws.cells(atColumns: [ColumnReference("C")!])
.filter { $0.type == "s" }
.compactMap { $0.value }
.compactMap { Int($0) }
.compactMap { sharedStrings.items[$0].text }

@murabye murabye closed this as completed Mar 18, 2019
@MaxDesiatov
Copy link
Collaborator

@murabye Glad to hear this fixes the issue for you. Please feel free to report any problems if you stumble upon any. Thank you for using CoreXLSX!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants