xlwings-utils 25.0.4__tar.gz → 25.0.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of xlwings-utils might be problematic. Click here for more details.
- {xlwings_utils-25.0.4 → xlwings_utils-25.0.5}/PKG-INFO +10 -10
- {xlwings_utils-25.0.4 → xlwings_utils-25.0.5}/README.md +9 -9
- {xlwings_utils-25.0.4 → xlwings_utils-25.0.5}/pyproject.toml +1 -1
- {xlwings_utils-25.0.4 → xlwings_utils-25.0.5}/xlwings_utils/xlwings_utils.py +66 -1
- {xlwings_utils-25.0.4 → xlwings_utils-25.0.5}/xlwings_utils.egg-info/PKG-INFO +10 -10
- {xlwings_utils-25.0.4 → xlwings_utils-25.0.5}/setup.cfg +0 -0
- {xlwings_utils-25.0.4 → xlwings_utils-25.0.5}/tests/test_xlwings_utils.py +0 -0
- {xlwings_utils-25.0.4 → xlwings_utils-25.0.5}/xlwings_utils/__init__.py +0 -0
- {xlwings_utils-25.0.4 → xlwings_utils-25.0.5}/xlwings_utils.egg-info/SOURCES.txt +0 -0
- {xlwings_utils-25.0.4 → xlwings_utils-25.0.5}/xlwings_utils.egg-info/dependency_links.txt +0 -0
- {xlwings_utils-25.0.4 → xlwings_utils-25.0.5}/xlwings_utils.egg-info/requires.txt +0 -0
- {xlwings_utils-25.0.4 → xlwings_utils-25.0.5}/xlwings_utils.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: xlwings_utils
|
|
3
|
-
Version: 25.0.
|
|
3
|
+
Version: 25.0.5
|
|
4
4
|
Summary: xlwings_utils
|
|
5
5
|
Author-email: Ruud van der Ham <rt.van.der.ham@gmail.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/salabim/xlwings_utils
|
|
@@ -19,7 +19,7 @@ This module provides some useful functions to be used in xlwings (lite).
|
|
|
19
19
|
|
|
20
20
|
## Installation
|
|
21
21
|
|
|
22
|
-
Just add `xlwings-utils` and `ssl` to the *requirements.txt* tab.
|
|
22
|
+
Just add `xlwings-utils` and `ssl` (even if `dropbox` is not used) to the *requirements.txt* tab.
|
|
23
23
|
|
|
24
24
|
In the script, add
|
|
25
25
|
|
|
@@ -49,7 +49,7 @@ If an application runs under xlwings, `xwu.xlwings` will be True. False, if not.
|
|
|
49
49
|
|
|
50
50
|
The xlwings lite system does not provide access to the local file system. With this module, files can be copied between Dropbox and the local pyodide file system, making it possible to indirectly use the local file system.
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
Currently, it is only possible to use full-access Dropbox apps.
|
|
53
53
|
|
|
54
54
|
The easiest way to use the Dropbox functionality is to add the credentials to the environment variables. Add REFRESH_TOKEN, APP_KEY and APP_SECRET with their corresponding values to the environment variables. Instructions on how to get these variables can be found here.
|
|
55
55
|
|
|
@@ -86,7 +86,7 @@ xwu.write_dropbox('/downloads/file1.gif')
|
|
|
86
86
|
## Block support
|
|
87
87
|
|
|
88
88
|
The module contains a useful 2-dimensional data structure: *block*.
|
|
89
|
-
This can be useful
|
|
89
|
+
This can be useful for manipulating a range without accessing it directly, which is expensive in terms of memory and execution time.
|
|
90
90
|
The advantage over an ordinary list of lists is that a block is index one-based, in line with range and addressing is done with a row, column tuple.
|
|
91
91
|
So, `my_block(lol)[row, col]` is roughly equivalent to `lol[row-1][col-1]`
|
|
92
92
|
|
|
@@ -136,7 +136,7 @@ for row in range(1, 10001):
|
|
|
136
136
|
this_block[row,2]= ...
|
|
137
137
|
if ...: # end condition
|
|
138
138
|
break
|
|
139
|
-
sheet.range(10,1).value = this_block.minimized().value
|
|
139
|
+
sheet.range((10,1)).value = this_block.minimized().value
|
|
140
140
|
```
|
|
141
141
|
|
|
142
142
|
In this case, only the really processed rows are copied to the sheet.
|
|
@@ -195,11 +195,11 @@ We then read the following rows (using hlookups) and access the required values.
|
|
|
195
195
|
|
|
196
196
|
### Filling a block from other sources
|
|
197
197
|
|
|
198
|
-
The advantage of using a block instead of accessing these sources is
|
|
198
|
+
The advantage of using a block instead of accessing these sources is that they are one-based, just like in Excel.
|
|
199
199
|
|
|
200
200
|
It is possible to make a block from an xlrd worksheet with `block.from_xlrd_sheet`.
|
|
201
201
|
|
|
202
|
-
It is possible to
|
|
202
|
+
It is possible to create a block from a Pandas DataFrame using `block.from_dataframe`. Ensure that, if the dataframe is created by reading from an Excel sheet, headers=None is specified, e.g., `df = pd.read_excel(filename, header=None)`.
|
|
203
203
|
|
|
204
204
|
It is possible to make a block from an openpyxl worksheet with `block.from_openpyxl_sheet`.
|
|
205
205
|
|
|
@@ -235,9 +235,9 @@ capture = xwu.Capture(include_print=True)
|
|
|
235
235
|
|
|
236
236
|
the stdout output is captured and printed.
|
|
237
237
|
|
|
238
|
-
Capturing
|
|
238
|
+
Capturing can be enabled and disabled at any time with `capture.enabled = True` and `capture.enabled = False`.
|
|
239
239
|
|
|
240
|
-
And
|
|
240
|
+
And include print, likewise, with `capture.include_print`.
|
|
241
241
|
|
|
242
242
|
Alternatively, a context manager is provided:
|
|
243
243
|
|
|
@@ -250,7 +250,7 @@ with capture:
|
|
|
250
250
|
```
|
|
251
251
|
Note that stopping the capture, leaves the captured output in place, so it can be extended later.
|
|
252
252
|
|
|
253
|
-
In either case, the captured output can be
|
|
253
|
+
In either case, the captured output can then be copied to a sheet, like
|
|
254
254
|
|
|
255
255
|
```
|
|
256
256
|
sheet.range(4,5).value = capture.value
|
|
@@ -6,7 +6,7 @@ This module provides some useful functions to be used in xlwings (lite).
|
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
9
|
-
Just add `xlwings-utils` and `ssl` to the *requirements.txt* tab.
|
|
9
|
+
Just add `xlwings-utils` and `ssl` (even if `dropbox` is not used) to the *requirements.txt* tab.
|
|
10
10
|
|
|
11
11
|
In the script, add
|
|
12
12
|
|
|
@@ -36,7 +36,7 @@ If an application runs under xlwings, `xwu.xlwings` will be True. False, if not.
|
|
|
36
36
|
|
|
37
37
|
The xlwings lite system does not provide access to the local file system. With this module, files can be copied between Dropbox and the local pyodide file system, making it possible to indirectly use the local file system.
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
Currently, it is only possible to use full-access Dropbox apps.
|
|
40
40
|
|
|
41
41
|
The easiest way to use the Dropbox functionality is to add the credentials to the environment variables. Add REFRESH_TOKEN, APP_KEY and APP_SECRET with their corresponding values to the environment variables. Instructions on how to get these variables can be found here.
|
|
42
42
|
|
|
@@ -73,7 +73,7 @@ xwu.write_dropbox('/downloads/file1.gif')
|
|
|
73
73
|
## Block support
|
|
74
74
|
|
|
75
75
|
The module contains a useful 2-dimensional data structure: *block*.
|
|
76
|
-
This can be useful
|
|
76
|
+
This can be useful for manipulating a range without accessing it directly, which is expensive in terms of memory and execution time.
|
|
77
77
|
The advantage over an ordinary list of lists is that a block is index one-based, in line with range and addressing is done with a row, column tuple.
|
|
78
78
|
So, `my_block(lol)[row, col]` is roughly equivalent to `lol[row-1][col-1]`
|
|
79
79
|
|
|
@@ -123,7 +123,7 @@ for row in range(1, 10001):
|
|
|
123
123
|
this_block[row,2]= ...
|
|
124
124
|
if ...: # end condition
|
|
125
125
|
break
|
|
126
|
-
sheet.range(10,1).value = this_block.minimized().value
|
|
126
|
+
sheet.range((10,1)).value = this_block.minimized().value
|
|
127
127
|
```
|
|
128
128
|
|
|
129
129
|
In this case, only the really processed rows are copied to the sheet.
|
|
@@ -182,11 +182,11 @@ We then read the following rows (using hlookups) and access the required values.
|
|
|
182
182
|
|
|
183
183
|
### Filling a block from other sources
|
|
184
184
|
|
|
185
|
-
The advantage of using a block instead of accessing these sources is
|
|
185
|
+
The advantage of using a block instead of accessing these sources is that they are one-based, just like in Excel.
|
|
186
186
|
|
|
187
187
|
It is possible to make a block from an xlrd worksheet with `block.from_xlrd_sheet`.
|
|
188
188
|
|
|
189
|
-
It is possible to
|
|
189
|
+
It is possible to create a block from a Pandas DataFrame using `block.from_dataframe`. Ensure that, if the dataframe is created by reading from an Excel sheet, headers=None is specified, e.g., `df = pd.read_excel(filename, header=None)`.
|
|
190
190
|
|
|
191
191
|
It is possible to make a block from an openpyxl worksheet with `block.from_openpyxl_sheet`.
|
|
192
192
|
|
|
@@ -222,9 +222,9 @@ capture = xwu.Capture(include_print=True)
|
|
|
222
222
|
|
|
223
223
|
the stdout output is captured and printed.
|
|
224
224
|
|
|
225
|
-
Capturing
|
|
225
|
+
Capturing can be enabled and disabled at any time with `capture.enabled = True` and `capture.enabled = False`.
|
|
226
226
|
|
|
227
|
-
And
|
|
227
|
+
And include print, likewise, with `capture.include_print`.
|
|
228
228
|
|
|
229
229
|
Alternatively, a context manager is provided:
|
|
230
230
|
|
|
@@ -237,7 +237,7 @@ with capture:
|
|
|
237
237
|
```
|
|
238
238
|
Note that stopping the capture, leaves the captured output in place, so it can be extended later.
|
|
239
239
|
|
|
240
|
-
In either case, the captured output can be
|
|
240
|
+
In either case, the captured output can then be copied to a sheet, like
|
|
241
241
|
|
|
242
242
|
```
|
|
243
243
|
sheet.range(4,5).value = capture.value
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
# /_/\_\|_| \_/\_/ |_||_| |_| \__, ||___/ _____ \__,_| \__||_||_||___/
|
|
6
6
|
# |___/ |_____|
|
|
7
7
|
|
|
8
|
-
__version__ = "25.0.
|
|
8
|
+
__version__ = "25.0.5"
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
import dropbox
|
|
@@ -13,6 +13,7 @@ from pathlib import Path
|
|
|
13
13
|
import os
|
|
14
14
|
import sys
|
|
15
15
|
import math
|
|
16
|
+
import base64
|
|
16
17
|
|
|
17
18
|
dbx = None
|
|
18
19
|
Pythonista = sys.platform == "ios"
|
|
@@ -786,5 +787,69 @@ class Capture:
|
|
|
786
787
|
self._include_print = value
|
|
787
788
|
|
|
788
789
|
|
|
790
|
+
def trigger_VBA(book):
|
|
791
|
+
"""
|
|
792
|
+
triggers the macro on sheet VBA in book
|
|
793
|
+
|
|
794
|
+
Parameters
|
|
795
|
+
----------
|
|
796
|
+
book : xw.Book
|
|
797
|
+
book to use
|
|
798
|
+
"""
|
|
799
|
+
|
|
800
|
+
book.sheets["VBA"]["A1"].value = "=NOW()"
|
|
801
|
+
|
|
802
|
+
|
|
803
|
+
def init_transfer_files(book):
|
|
804
|
+
"""
|
|
805
|
+
initializes the file info on sheet VBA in book
|
|
806
|
+
|
|
807
|
+
should be called prior to calling any transfer_file()
|
|
808
|
+
|
|
809
|
+
Parameters
|
|
810
|
+
----------
|
|
811
|
+
book : xw.Book
|
|
812
|
+
book to use
|
|
813
|
+
"""
|
|
814
|
+
|
|
815
|
+
global row1
|
|
816
|
+
book.sheets["VBA"].range((10, 1), (1000000, 1)).clear()
|
|
817
|
+
row1 = 10
|
|
818
|
+
|
|
819
|
+
|
|
820
|
+
def transfer_file(book, file):
|
|
821
|
+
"""
|
|
822
|
+
makes the local file to be encoded on sheet VBA in book
|
|
823
|
+
to be triggered later
|
|
824
|
+
|
|
825
|
+
init_transfer_files should be called prior to any transfer_file()
|
|
826
|
+
|
|
827
|
+
Parameters
|
|
828
|
+
----------
|
|
829
|
+
book : xw.Book
|
|
830
|
+
book to use
|
|
831
|
+
|
|
832
|
+
file : string
|
|
833
|
+
name of file to be encoded
|
|
834
|
+
"""
|
|
835
|
+
|
|
836
|
+
global row1
|
|
837
|
+
ws = book.sheets("VBA")
|
|
838
|
+
ws_block = block(number_of_rows=50000, number_of_columns=1)
|
|
839
|
+
n = 5000 # block size
|
|
840
|
+
row = 1
|
|
841
|
+
ws_block[row, 1] = f"<file={file}>"
|
|
842
|
+
row += 1
|
|
843
|
+
b64 = base64.b64encode(open(file, "rb").read()).decode("utf-8")
|
|
844
|
+
while b64:
|
|
845
|
+
b64_n = b64[:n]
|
|
846
|
+
ws_block[row, 1] = b64_n
|
|
847
|
+
row += 1
|
|
848
|
+
b64 = b64[n:]
|
|
849
|
+
ws_block[row, 1] = f"</file>"
|
|
850
|
+
ws.range((row1, 1)).value = ws_block.minimized().value
|
|
851
|
+
row1 += ws_block.highest_used_row_number
|
|
852
|
+
|
|
853
|
+
|
|
789
854
|
if __name__ == "__main__":
|
|
790
855
|
...
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: xlwings_utils
|
|
3
|
-
Version: 25.0.
|
|
3
|
+
Version: 25.0.5
|
|
4
4
|
Summary: xlwings_utils
|
|
5
5
|
Author-email: Ruud van der Ham <rt.van.der.ham@gmail.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/salabim/xlwings_utils
|
|
@@ -19,7 +19,7 @@ This module provides some useful functions to be used in xlwings (lite).
|
|
|
19
19
|
|
|
20
20
|
## Installation
|
|
21
21
|
|
|
22
|
-
Just add `xlwings-utils` and `ssl` to the *requirements.txt* tab.
|
|
22
|
+
Just add `xlwings-utils` and `ssl` (even if `dropbox` is not used) to the *requirements.txt* tab.
|
|
23
23
|
|
|
24
24
|
In the script, add
|
|
25
25
|
|
|
@@ -49,7 +49,7 @@ If an application runs under xlwings, `xwu.xlwings` will be True. False, if not.
|
|
|
49
49
|
|
|
50
50
|
The xlwings lite system does not provide access to the local file system. With this module, files can be copied between Dropbox and the local pyodide file system, making it possible to indirectly use the local file system.
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
Currently, it is only possible to use full-access Dropbox apps.
|
|
53
53
|
|
|
54
54
|
The easiest way to use the Dropbox functionality is to add the credentials to the environment variables. Add REFRESH_TOKEN, APP_KEY and APP_SECRET with their corresponding values to the environment variables. Instructions on how to get these variables can be found here.
|
|
55
55
|
|
|
@@ -86,7 +86,7 @@ xwu.write_dropbox('/downloads/file1.gif')
|
|
|
86
86
|
## Block support
|
|
87
87
|
|
|
88
88
|
The module contains a useful 2-dimensional data structure: *block*.
|
|
89
|
-
This can be useful
|
|
89
|
+
This can be useful for manipulating a range without accessing it directly, which is expensive in terms of memory and execution time.
|
|
90
90
|
The advantage over an ordinary list of lists is that a block is index one-based, in line with range and addressing is done with a row, column tuple.
|
|
91
91
|
So, `my_block(lol)[row, col]` is roughly equivalent to `lol[row-1][col-1]`
|
|
92
92
|
|
|
@@ -136,7 +136,7 @@ for row in range(1, 10001):
|
|
|
136
136
|
this_block[row,2]= ...
|
|
137
137
|
if ...: # end condition
|
|
138
138
|
break
|
|
139
|
-
sheet.range(10,1).value = this_block.minimized().value
|
|
139
|
+
sheet.range((10,1)).value = this_block.minimized().value
|
|
140
140
|
```
|
|
141
141
|
|
|
142
142
|
In this case, only the really processed rows are copied to the sheet.
|
|
@@ -195,11 +195,11 @@ We then read the following rows (using hlookups) and access the required values.
|
|
|
195
195
|
|
|
196
196
|
### Filling a block from other sources
|
|
197
197
|
|
|
198
|
-
The advantage of using a block instead of accessing these sources is
|
|
198
|
+
The advantage of using a block instead of accessing these sources is that they are one-based, just like in Excel.
|
|
199
199
|
|
|
200
200
|
It is possible to make a block from an xlrd worksheet with `block.from_xlrd_sheet`.
|
|
201
201
|
|
|
202
|
-
It is possible to
|
|
202
|
+
It is possible to create a block from a Pandas DataFrame using `block.from_dataframe`. Ensure that, if the dataframe is created by reading from an Excel sheet, headers=None is specified, e.g., `df = pd.read_excel(filename, header=None)`.
|
|
203
203
|
|
|
204
204
|
It is possible to make a block from an openpyxl worksheet with `block.from_openpyxl_sheet`.
|
|
205
205
|
|
|
@@ -235,9 +235,9 @@ capture = xwu.Capture(include_print=True)
|
|
|
235
235
|
|
|
236
236
|
the stdout output is captured and printed.
|
|
237
237
|
|
|
238
|
-
Capturing
|
|
238
|
+
Capturing can be enabled and disabled at any time with `capture.enabled = True` and `capture.enabled = False`.
|
|
239
239
|
|
|
240
|
-
And
|
|
240
|
+
And include print, likewise, with `capture.include_print`.
|
|
241
241
|
|
|
242
242
|
Alternatively, a context manager is provided:
|
|
243
243
|
|
|
@@ -250,7 +250,7 @@ with capture:
|
|
|
250
250
|
```
|
|
251
251
|
Note that stopping the capture, leaves the captured output in place, so it can be extended later.
|
|
252
252
|
|
|
253
|
-
In either case, the captured output can be
|
|
253
|
+
In either case, the captured output can then be copied to a sheet, like
|
|
254
254
|
|
|
255
255
|
```
|
|
256
256
|
sheet.range(4,5).value = capture.value
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|