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

Add support for missing cell reference #10

Merged
merged 1 commit into from
Nov 13, 2023

Conversation

velios
Copy link
Contributor

@velios velios commented Nov 12, 2023

No description provided.

Comment on lines -38 to -69
(def tags
"Map of Excel XML namespaces of interest"
{:sheet-tag #{:sheets
:xmlns.http%3A%2F%2Fschemas.openxmlformats.org%2Fspreadsheetml%2F2006%2Fmain/sheets
:xmlns.http%3A%2F%2Fpurl.oclc.org%2Fooxml%2Fspreadsheetml%2Fmain/sheets}
:row-tag #{:row
:xmlns.http%3A%2F%2Fschemas.openxmlformats.org%2Fspreadsheetml%2F2006%2Fmain/row
:xmlns.http%3A%2F%2Fpurl.oclc.org%2Fooxml%2Fspreadsheetml%2Fmain/row}
:text-part #{:si
:xmlns.http%3A%2F%2Fschemas.openxmlformats.org%2Fspreadsheetml%2F2006%2Fmain/si
:xmlns.http%3A%2F%2Fpurl.oclc.org%2Fooxml%2Fspreadsheetml%2Fmain/si}
:numFmts #{:numFmts
:xmlns.http%3A%2F%2Fschemas.openxmlformats.org%2Fspreadsheetml%2F2006%2Fmain/numFmts
:xmlns.http%3A%2F%2Fpurl.oclc.org%2Fooxml%2Fspreadsheetml%2Fmain/numFmts}
:cellxfs #{:cellXfs
:xmlns.http%3A%2F%2Fschemas.openxmlformats.org%2Fspreadsheetml%2F2006%2Fmain/cellXfs
:xmlns.http%3A%2F%2Fpurl.oclc.org%2Fooxml%2Fspreadsheetml%2Fmain/cellXfs}
:xf #{:xf
:xmlns.http%3A%2F%2Fschemas.openxmlformats.org%2Fspreadsheetml%2F2006%2Fmain/xf
:xmlns.http%3A%2F%2Fpurl.oclc.org%2Fooxml%2Fspreadsheetml%2Fmain/xf}
:text-t #{:t
:xmlns.http%3A%2F%2Fschemas.openxmlformats.org%2Fspreadsheetml%2F2006%2Fmain/t
:xmlns.http%3A%2F%2Fpurl.oclc.org%2Fooxml%2Fspreadsheetml%2Fmain/t}
:text-r #{:r
:xmlns.http%3A%2F%2Fschemas.openxmlformats.org%2Fspreadsheetml%2F2006%2Fmain/r
:xmlns.http%3A%2F%2Fpurl.oclc.org%2Fooxml%2Fspreadsheetml%2Fmain/r}
:sheet-data #{:sheetData
:xmlns.http%3A%2F%2Fschemas.openxmlformats.org%2Fspreadsheetml%2F2006%2Fmain/sheetData
:xmlns.http%3A%2F%2Fpurl.oclc.org%2Fooxml%2Fspreadsheetml%2Fmain/sheetData}
:sheet-id #{:id
:xmlns.http%3A%2F%2Fschemas.openxmlformats.org%2FofficeDocument%2F2006%2Frelationships/id
:xmlns.http%3A%2F%2Fpurl.oclc.org%2Fooxml%2FofficeDocument%2Frelationships/id}})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With namespace-aware arg of (xml/parse styles {:namespace-aware false}) and by-tag pred in util ns i thought we can avoid verbose tag description

[^ZipFile zipfile]
(if-let [wb (.getEntry zipfile "xl/styles.xml")]
(let [ins (.getInputStream zipfile wb)
x (parse-str (slurp ins))]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change here and next slurp to .getInputStream for optimal memory usage

src/bb_excel/core.clj Outdated Show resolved Hide resolved
Comment on lines +168 to +176
(defn number->column-letter
[n]
(loop [num n
acc ""]
(if (> num 0)
(let [residue (mod (dec num) 26)
new-num (quot (dec num) 26)]
(recur new-num (str (char (+ residue A_CHAR_INDEX)) acc)))
acc)))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this functionality can add new option to retrieve rows with number cell index If this may be of interest to anyone

Copy link
Contributor Author

@velios velios left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After PR work faster in my test one colum file with 1048576 rows, like 25% of perfomance rise

wip

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix
Copy link
Contributor Author

@velios velios left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question about current functionality

@kbosompem kbosompem merged commit df024bd into kbosompem:main Nov 13, 2023
1 check passed
@velios velios deleted the refactoring branch November 13, 2023 06:05
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

Successfully merging this pull request may close these issues.

2 participants