openpyxl merge requestshttps://foss.heptapod.net/openpyxl/openpyxl/-/merge_requests2024-03-16T13:57:22Zhttps://foss.heptapod.net/openpyxl/openpyxl/-/merge_requests/441Add myself to Authors2024-03-16T13:57:22ZPrimož GodecAdd myself to AuthorsSince I was asked in https://foss.heptapod.net/openpyxl/openpyxl/-/merge_requests/436#note_347052 to add myself in Authors, I am adding myself now.
--HG--
branch : 3.1Since I was asked in https://foss.heptapod.net/openpyxl/openpyxl/-/merge_requests/436#note_347052 to add myself in Authors, I am adding myself now.
--HG--
branch : 3.1https://foss.heptapod.net/openpyxl/openpyxl/-/merge_requests/440RTD now wants a config file.2024-03-11T11:33:49ZCharlieCRTD now wants a config file.--HG--
branch : 3.1--HG--
branch : 3.1https://foss.heptapod.net/openpyxl/openpyxl/-/merge_requests/436[FIX] Close opened worksheet file that preven't zip closure2024-03-16T12:40:51ZPrimož Godec[FIX] Close opened worksheet file that preven't zip closure### Issue
In newer Python versions >=3.11.8 or >=3.12.2, something seems to change in the garbage collection of the open archive file when the `read_worksheets` function finishes (the worksheet file seems to stay open when the function ...### Issue
In newer Python versions >=3.11.8 or >=3.12.2, something seems to change in the garbage collection of the open archive file when the `read_worksheets` function finishes (the worksheet file seems to stay open when the function finishes - before it was closed by Python). It causes the archive not to close when `self.archive.close()` is called but Python closes it when the script finishes. More here: https://foss.heptapod.net/openpyxl/openpyxl/-/issues/2149#note_345410
### Change
This MR ensures that the worksheet file closes.
--HG--
branch : 3.1https://foss.heptapod.net/openpyxl/openpyxl/-/merge_requests/435remove deprecated use of datetime utcnow2023-12-11T19:38:41ZRafael Santosremove deprecated use of datetime utcnowCloses #2051
--HG--
branch : 3.1Closes #2051
--HG--
branch : 3.1https://foss.heptapod.net/openpyxl/openpyxl/-/merge_requests/431Changed the default value for the "allow_blank" parameter to None2024-03-10T15:08:18ZTimoChanged the default value for the "allow_blank" parameter to NoneWhile developing with this helpful library, I noticed that when editing a document with validation that the XML attribute `allow_blank` was dropped from the data validation object. After some debugging, I found out, that the default valu...While developing with this helpful library, I noticed that when editing a document with validation that the XML attribute `allow_blank` was dropped from the data validation object. After some debugging, I found out, that the default value of the `allow_blank` parameter in the constructor of the `DataValidation` class overrode the actual value passed to the `allowBlank` parameter.
Probably further testing would have prevented this bug from being implemented in !419, but for now I have simply corrected the default value for the `allow_blank` parameter to `None`, which should fix the bug and not change the idea behind the default values.https://foss.heptapod.net/openpyxl/openpyxl/-/merge_requests/429Added several tests for the rich_text._opt() method2023-06-30T08:33:07ZUdi FinkelsteinAdded several tests for the rich_text._opt() method--HG--
branch : 3.1
This pull request adds several tests for the _opt method in the CellRichText class.--HG--
branch : 3.1
This pull request adds several tests for the _opt method in the CellRichText class.https://foss.heptapod.net/openpyxl/openpyxl/-/merge_requests/428fix false positive in is_date_format detection.2023-04-19T12:59:04ZLennart Brinkmannfix false positive in is_date_format detection.According to the spec `_` (underline) denotes a skip the width of the next character.
So the underline should be added to the negative lookbehind in the regex.
Resolves #2014.According to the spec `_` (underline) denotes a skip the width of the next character.
So the underline should be added to the negative lookbehind in the regex.
Resolves #2014.https://foss.heptapod.net/openpyxl/openpyxl/-/merge_requests/427Fix read only worksheets incorrectly handling datetime and timedelta objects ...2023-03-14T14:10:02ZsnippetFix read only worksheets incorrectly handling datetime and timedelta objects when parsingFixes issue #1973 , timedelta cells are correctly identified now. Added tests
--HG--
branch : 3.1Fixes issue #1973 , timedelta cells are correctly identified now. Added tests
--HG--
branch : 3.1https://foss.heptapod.net/openpyxl/openpyxl/-/merge_requests/426Fix formulae that had not been properly split out2023-03-14T10:43:25ZsnippetFix formulae that had not been properly split outFixes the 4 broken formulae listed in #1987. Does this require a test as well? The list could be parsed for if there's a " " in the token and if so, fail. I assume we're never going to get formulae with spaces...
Also I've added myself t...Fixes the 4 broken formulae listed in #1987. Does this require a test as well? The list could be parsed for if there's a " " in the token and if so, fail. I assume we're never going to get formulae with spaces...
Also I've added myself to the authors.
--HG--
branch : 3.1https://foss.heptapod.net/openpyxl/openpyxl/-/merge_requests/424Fix print area being set to a table name2024-03-21T08:32:43ZsnippetFix print area being set to a table nameResolves issue #1942. Parsing documents with print areas set to table names will now issue a warning and just ignore the print area for that sheet.
Openpyxl cannot be reasonably expected to process defined names for print areas if they'...Resolves issue #1942. Parsing documents with print areas set to table names will now issue a warning and just ignore the print area for that sheet.
Openpyxl cannot be reasonably expected to process defined names for print areas if they're set to table names. While this may have been possible if the range was always the entire table, Excel also allows setting it to only a few columns in the table which adds unreasonable complexity.
--HG--
branch : 3.1https://foss.heptapod.net/openpyxl/openpyxl/-/merge_requests/423Update dataframe_to_rows to fix uneven indices2023-02-01T09:06:03ZsnippetUpdate dataframe_to_rows to fix uneven indicesThis should resolve #1904 and #1908.
The change to the test is just making the index uneven in size in case there's some future change to it.
Thanks to @xrcyz for the assistance debugging it.
--HG--
branch : 3.1This should resolve #1904 and #1908.
The change to the test is just making the index uneven in size in case there's some future change to it.
Thanks to @xrcyz for the assistance debugging it.
--HG--
branch : 3.1https://foss.heptapod.net/openpyxl/openpyxl/-/merge_requests/422Fix build pipeline, cobertura syntax changed2022-11-09T15:25:35ZsnippetFix build pipeline, cobertura syntax changedThe syntax around cobertura changed in a recent GitLab release which I guess was recently integrated into Heptapod - https://gitlab.com/gitlab-org/gitlab/-/issues/361615#note_937496084
The remaining issues with CI seem related to pytest...The syntax around cobertura changed in a recent GitLab release which I guess was recently integrated into Heptapod - https://gitlab.com/gitlab-org/gitlab/-/issues/361615#note_937496084
The remaining issues with CI seem related to pytest, it appears they've removed `py` as a dependency as the library has been somewhat retired (ref. https://github.com/pytest-dev/pytest/pull/10396 and https://pypi.org/project/py/)
It seems there's a fair bit of py.path used throughout the code and their proposed fix is to swap that to pathlib. I can make those changes or we can add `py` as a dependency, either would fix it.
--HG--
branch : 3.1snippetsnippethttps://foss.heptapod.net/openpyxl/openpyxl/-/merge_requests/421Update docs.2022-11-09T16:54:26ZsnippetUpdate docs.Adding more examples to the docs, cleaning up unused code.
--HG--
branch : 3.1Adding more examples to the docs, cleaning up unused code.
--HG--
branch : 3.1https://foss.heptapod.net/openpyxl/openpyxl/-/merge_requests/420Allow Image to optinally have alt text specified2023-11-01T23:22:11ZsnippetAllow Image to optinally have alt text specifiedOptionally allow `Image(img)` to be called with `Image(img, 'this is alt text')` which would set 'this alt text' on an image. Adds a `desc` property to the `Image` class which stores the description. Should close #1850
This is the reba...Optionally allow `Image(img)` to be called with `Image(img, 'this is alt text')` which would set 'this alt text' on an image. Adds a `desc` property to the `Image` class which stores the description. Should close #1850
This is the rebasing of !417
--HG--
branch : 3.2https://foss.heptapod.net/openpyxl/openpyxl/-/merge_requests/419Update dataValidation to match spec2023-08-30T09:09:12ZsnippetUpdate dataValidation to match specThe spec suggests that `showInputMessage` and `showErrorMessage` should be optional and default to `False`. Updated DataValidation class to match
Ref. https://c-rex.net/projects/samples/ooxml/e1/Part4/OOXML_P4_DOCX_dataValidation_topic_...The spec suggests that `showInputMessage` and `showErrorMessage` should be optional and default to `False`. Updated DataValidation class to match
Ref. https://c-rex.net/projects/samples/ooxml/e1/Part4/OOXML_P4_DOCX_dataValidation_topic_ID0E1DW4.html
Closes #1732
This is the same as !418 but properly rebased to 3.1
--HG--
branch : 3.1https://foss.heptapod.net/openpyxl/openpyxl/-/merge_requests/415Allowed setting print area to None or an empty list to clear the print area2022-07-15T08:10:16ZsnippetAllowed setting print area to None or an empty list to clear the print areaCloses https://foss.heptapod.net/openpyxl/openpyxl/-/issues/1851
--HG--
branch : 3.0Closes https://foss.heptapod.net/openpyxl/openpyxl/-/issues/1851
--HG--
branch : 3.0https://foss.heptapod.net/openpyxl/openpyxl/-/merge_requests/412Support for ActiveX objects and form controls2022-01-13T16:16:50ZCharlieCSupport for ActiveX objects and form controlsAdds support for ActiveX controls including the binary objectsAdds support for ActiveX controls including the binary objectsCharlieCCharlieChttps://foss.heptapod.net/openpyxl/openpyxl/-/merge_requests/411Add information to the ValueError when loading xlsx fails2022-02-21T13:50:19ZAnthony HaywardAdd information to the ValueError when loading xlsx failsInformation added to `ValueError` output:
- Name of file that failed to load. Could be helpful if a failing script loads multiple xslx files.
- Identify which step of the loading process caused the error.
- Show the element name in the ...Information added to `ValueError` output:
- Name of file that failed to load. Could be helpful if a failing script loads multiple xslx files.
- Identify which step of the loading process caused the error.
- Show the element name in the stylesheet that was invalid, and also the invalid value, not just the permitted values.
# Error output
In this example, `c:\temp\bad.xlsx` contains invalid `<u val="1"/>` as described in https://foss.heptapod.net/openpyxl/openpyxl/-/issues/1766
## Before
```
openpyxl.load_workbook(r"c:\temp\bad.xlsx")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\code\oss\openpyxl\openpyxl\reader\excel.py", line 322, in load_workbook
reader.read()
File "C:\code\oss\openpyxl\openpyxl\reader\excel.py", line 286, in read
apply_stylesheet(self.archive, self.wb)
File "C:\code\oss\openpyxl\openpyxl\styles\stylesheet.py", line 198, in apply_stylesheet
stylesheet = Stylesheet.from_tree(node)
File "C:\code\oss\openpyxl\openpyxl\styles\stylesheet.py", line 103, in from_tree
return super(Stylesheet, cls).from_tree(node)
File "C:\code\oss\openpyxl\openpyxl\descriptors\serialisable.py", line 83, in from_tree
obj = desc.from_tree(el)
File "C:\code\oss\openpyxl\openpyxl\descriptors\sequence.py", line 85, in from_tree
return [self.expected_type.from_tree(el) for el in node]
File "C:\code\oss\openpyxl\openpyxl\descriptors\sequence.py", line 85, in <listcomp>
return [self.expected_type.from_tree(el) for el in node]
File "C:\code\oss\openpyxl\openpyxl\styles\fonts.py", line 109, in from_tree
return super(Font, cls).from_tree(node)
File "C:\code\oss\openpyxl\openpyxl\descriptors\serialisable.py", line 103, in from_tree
return cls(**attrib)
File "C:\code\oss\openpyxl\openpyxl\styles\fonts.py", line 87, in __init__
self.u = u
File "C:\code\oss\openpyxl\openpyxl\descriptors\nested.py", line 35, in __set__
super(Nested, self).__set__(instance, value)
File "C:\code\oss\openpyxl\openpyxl\descriptors\base.py", line 143, in __set__
super(NoneSet, self).__set__(instance, value)
File "C:\code\oss\openpyxl\openpyxl\descriptors\base.py", line 128, in __set__
raise ValueError(self.__doc__)
ValueError: Value must be one of {'double', 'singleAccounting', 'doubleAccounting', 'single'}
```
## After
```
openpyxl.load_workbook(r"c:\temp\bad.xlsx")
Traceback (most recent call last):
File "C:\code\oss\openpyxl\openpyxl\reader\excel.py", line 293, in read
apply_stylesheet(self.archive, self.wb)
File "C:\code\oss\openpyxl\openpyxl\styles\stylesheet.py", line 198, in apply_stylesheet
stylesheet = Stylesheet.from_tree(node)
File "C:\code\oss\openpyxl\openpyxl\styles\stylesheet.py", line 103, in from_tree
return super(Stylesheet, cls).from_tree(node)
File "C:\code\oss\openpyxl\openpyxl\descriptors\serialisable.py", line 83, in from_tree
obj = desc.from_tree(el)
File "C:\code\oss\openpyxl\openpyxl\descriptors\sequence.py", line 85, in from_tree
return [self.expected_type.from_tree(el) for el in node]
File "C:\code\oss\openpyxl\openpyxl\descriptors\sequence.py", line 85, in <listcomp>
return [self.expected_type.from_tree(el) for el in node]
File "C:\code\oss\openpyxl\openpyxl\styles\fonts.py", line 109, in from_tree
return super(Font, cls).from_tree(node)
File "C:\code\oss\openpyxl\openpyxl\descriptors\serialisable.py", line 103, in from_tree
return cls(**attrib)
File "C:\code\oss\openpyxl\openpyxl\styles\fonts.py", line 87, in __init__
self.u = u
File "C:\code\oss\openpyxl\openpyxl\descriptors\nested.py", line 35, in __set__
super(Nested, self).__set__(instance, value)
File "C:\code\oss\openpyxl\openpyxl\descriptors\base.py", line 147, in __set__
super(NoneSet, self).__set__(instance, value)
File "C:\code\oss\openpyxl\openpyxl\descriptors\base.py", line 132, in __set__
raise ValueError(message)
ValueError: Value for 'u' must be one of {'doubleAccounting', 'single', None, 'double', 'singleAccounting'}, but '1' was found
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\code\oss\openpyxl\openpyxl\reader\excel.py", line 334, in load_workbook
data_only, keep_links)
File "C:\code\oss\openpyxl\openpyxl\reader\excel.py", line 302, in read
self.archive.close()
ValueError: Failed to load Excel file: could not read stylesheet from C:\temp\bad.xlsx
```
I've added pytests and checked that it works on Python 3.6 as well as 3.9.
--HG--
branch : 3.1CharlieCCharlieChttps://foss.heptapod.net/openpyxl/openpyxl/-/merge_requests/409New 3.1-based work on rich text2022-04-21T23:20:04ZUdi FinkelsteinNew 3.1-based work on rich textThis pull request replaces merge request !408, due to two main reasons:
1. It was based on the 3.0 branch, not 3.1
2. It stored rich text as low level XML Elements. While this worked for creating new content,
it wasn't very user-frien...This pull request replaces merge request !408, due to two main reasons:
1. It was based on the 3.0 branch, not 3.1
2. It stored rich text as low level XML Elements. While this worked for creating new content,
it wasn't very user-friendly for analyzing existing rich text cells.
At @charlie.clark request, discussions of this feature are now on https://groups.google.com/g/openpyxl-users/c/fV3GnRjvbm8
--HG--
branch : 3.1https://foss.heptapod.net/openpyxl/openpyxl/-/merge_requests/407Support for Custom Properties (continued)2022-06-06T15:41:58ZCharlieCSupport for Custom Properties (continued)The original got PR got merged automatically, but seeing as tests still fail on this, we need an open one for discussion.The original got PR got merged automatically, but seeing as tests still fail on this, we need an open one for discussion.