xlwings-utils 25.0.6__tar.gz → 25.0.6.post0__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.6 → xlwings_utils-25.0.6.post0}/PKG-INFO +27 -59
- {xlwings_utils-25.0.6 → xlwings_utils-25.0.6.post0}/README.md +26 -58
- {xlwings_utils-25.0.6 → xlwings_utils-25.0.6.post0}/pyproject.toml +1 -1
- {xlwings_utils-25.0.6 → xlwings_utils-25.0.6.post0}/xlwings_utils/xlwings_utils.py +45 -30
- {xlwings_utils-25.0.6 → xlwings_utils-25.0.6.post0}/xlwings_utils.egg-info/PKG-INFO +27 -59
- {xlwings_utils-25.0.6 → xlwings_utils-25.0.6.post0}/setup.cfg +0 -0
- {xlwings_utils-25.0.6 → xlwings_utils-25.0.6.post0}/tests/test_xlwings_utils.py +0 -0
- {xlwings_utils-25.0.6 → xlwings_utils-25.0.6.post0}/xlwings_utils/__init__.py +0 -0
- {xlwings_utils-25.0.6 → xlwings_utils-25.0.6.post0}/xlwings_utils.egg-info/SOURCES.txt +0 -0
- {xlwings_utils-25.0.6 → xlwings_utils-25.0.6.post0}/xlwings_utils.egg-info/dependency_links.txt +0 -0
- {xlwings_utils-25.0.6 → xlwings_utils-25.0.6.post0}/xlwings_utils.egg-info/requires.txt +0 -0
- {xlwings_utils-25.0.6 → xlwings_utils-25.0.6.post0}/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.6
|
|
3
|
+
Version: 25.0.6.post0
|
|
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
|
|
@@ -62,7 +62,7 @@ python -c "exec(__import__('requests').get('https://salabim.org/dropbox setup.py
|
|
|
62
62
|
Then, it is possible to list all files in a specified folder using the list_dropbox function.
|
|
63
63
|
It is also possible to get the folders and to access all underlying folders.
|
|
64
64
|
|
|
65
|
-
The `read_dropbox` function can be used to read the contents (bytes) of a Dropbox file. As reading from Dropbox under pyodide is
|
|
65
|
+
The `read_dropbox` function can be used to read the contents (bytes) of a Dropbox file. As reading from Dropbox under pyodide is rather unreliable, xlwings_utils automatically retries several times (by default 100 times). The actual number of retries can be found with `read_dropbox.retries`.
|
|
66
66
|
|
|
67
67
|
The function `write_dropbox` can be used to write contents (bytes) to a Dropbox file.
|
|
68
68
|
|
|
@@ -269,11 +269,11 @@ Currently, *xlwings Lite* does not provide access to the local file system. Ther
|
|
|
269
269
|
Files can be encoded into a block, like:
|
|
270
270
|
|
|
271
271
|
```
|
|
272
|
-
bl = xwu.block.
|
|
273
|
-
book.sheets["VBA"].range((10,
|
|
272
|
+
bl = xwu.block.encode_file("film1.mp4")
|
|
273
|
+
book.sheets["VBA"].range((10,1)).value=bl.value
|
|
274
274
|
```
|
|
275
275
|
|
|
276
|
-
With this code, column
|
|
276
|
+
With this code, column A will be filled with an encoded copy of the files *film1.mp4* . This can then be used with a suitable VBA macro to decode to the real file system. A VBA macro can be triggered with `xwu.trigger_macro()`. This requires an Excel worksheet where cell A1 is reserved for communication with xlwings lite. This worksheet needs to contain a macro, like
|
|
277
277
|
|
|
278
278
|
```
|
|
279
279
|
Private Sub Worksheet_Calculate()
|
|
@@ -284,66 +284,34 @@ Private Sub Worksheet_Calculate()
|
|
|
284
284
|
End Sub
|
|
285
285
|
```
|
|
286
286
|
|
|
287
|
-
, where `MacroToExecute` should contain the user code, most likely code to decode
|
|
287
|
+
, where `MacroToExecute` should contain the user code, most likely code to decode file(s) encoded.
|
|
288
|
+
|
|
289
|
+
The repo contains a VBA module called xlwings_utils.bas with code to decode encoded files.
|
|
290
|
+
Just add the .bas file to a worksheet and call like
|
|
288
291
|
|
|
289
292
|
```
|
|
290
|
-
|
|
293
|
+
Sub MacroToExecute()
|
|
294
|
+
DecodeFile(Me, 10, 1)
|
|
291
295
|
```
|
|
296
|
+
|
|
297
|
+
In this example, the file *film1.mp4* will be downloaded into the current directory.
|
|
292
298
|
|
|
293
|
-
The
|
|
299
|
+
The module xlwings_utils also contains code to encode a local file to a sheet:
|
|
294
300
|
|
|
295
301
|
```
|
|
296
|
-
Sub
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
ThisDir = ThisWorkbook.Path
|
|
310
|
-
Set ws = Me
|
|
311
|
-
Count = 0
|
|
312
|
-
While Row < 30000
|
|
313
|
-
Line = ws.Cells(Row, Column)
|
|
314
|
-
If InStr(Line, "<file=") = 1 And Right(Line, 1) = ">" Then
|
|
315
|
-
If Count <> 0 Then
|
|
316
|
-
FileNames = FileNames & ", "
|
|
317
|
-
End If
|
|
318
|
-
Count = Count + 1
|
|
319
|
-
FileNameOnly = Mid(Line, 7, Len(Line) - 7)
|
|
320
|
-
Filename = ThisDir & "/" & FileNameOnly
|
|
321
|
-
FileNames = FileNames & FileNameOnly
|
|
322
|
-
|
|
323
|
-
Row = Row + 1
|
|
324
|
-
S = ""
|
|
325
|
-
While ws.Cells(Row, Column) <> "</file>"
|
|
326
|
-
S = S & ws.Cells(Row, Column)
|
|
327
|
-
Row = Row + 1
|
|
328
|
-
Wend
|
|
329
|
-
|
|
330
|
-
vArr = Base64ToArray(S)
|
|
331
|
-
|
|
332
|
-
Open Filename For Binary Access Write As #1
|
|
333
|
-
WritePos = 1
|
|
334
|
-
Put #1, WritePos, vArr
|
|
335
|
-
Close #1
|
|
336
|
-
End If
|
|
337
|
-
|
|
338
|
-
Row = Row + 1
|
|
339
|
-
|
|
340
|
-
Wend
|
|
341
|
-
|
|
342
|
-
If Count = 0 Then
|
|
343
|
-
MsgBox "No files to decode"
|
|
344
|
-
Else
|
|
345
|
-
MsgBox "Successfully decoded and written " & Str(Count) & " file(s): " & FileNames
|
|
346
|
-
End If
|
|
302
|
+
Sub MacroToExecute()
|
|
303
|
+
EncodeFile(Me, "data.json", 10, 1)
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
This will place an encoded version of *data.json* on the sheet.
|
|
307
|
+
|
|
308
|
+
Then, the file can be copied to the pyodide file system with
|
|
309
|
+
|
|
310
|
+
```
|
|
311
|
+
bl = block(xw.range((10,1),(50000,1)).decode_to_files())
|
|
312
|
+
```
|
|
313
|
+
```
|
|
314
|
+
|
|
347
315
|
```
|
|
348
316
|
|
|
349
317
|
## Contact info
|
|
@@ -49,7 +49,7 @@ python -c "exec(__import__('requests').get('https://salabim.org/dropbox setup.py
|
|
|
49
49
|
Then, it is possible to list all files in a specified folder using the list_dropbox function.
|
|
50
50
|
It is also possible to get the folders and to access all underlying folders.
|
|
51
51
|
|
|
52
|
-
The `read_dropbox` function can be used to read the contents (bytes) of a Dropbox file. As reading from Dropbox under pyodide is
|
|
52
|
+
The `read_dropbox` function can be used to read the contents (bytes) of a Dropbox file. As reading from Dropbox under pyodide is rather unreliable, xlwings_utils automatically retries several times (by default 100 times). The actual number of retries can be found with `read_dropbox.retries`.
|
|
53
53
|
|
|
54
54
|
The function `write_dropbox` can be used to write contents (bytes) to a Dropbox file.
|
|
55
55
|
|
|
@@ -256,11 +256,11 @@ Currently, *xlwings Lite* does not provide access to the local file system. Ther
|
|
|
256
256
|
Files can be encoded into a block, like:
|
|
257
257
|
|
|
258
258
|
```
|
|
259
|
-
bl = xwu.block.
|
|
260
|
-
book.sheets["VBA"].range((10,
|
|
259
|
+
bl = xwu.block.encode_file("film1.mp4")
|
|
260
|
+
book.sheets["VBA"].range((10,1)).value=bl.value
|
|
261
261
|
```
|
|
262
262
|
|
|
263
|
-
With this code, column
|
|
263
|
+
With this code, column A will be filled with an encoded copy of the files *film1.mp4* . This can then be used with a suitable VBA macro to decode to the real file system. A VBA macro can be triggered with `xwu.trigger_macro()`. This requires an Excel worksheet where cell A1 is reserved for communication with xlwings lite. This worksheet needs to contain a macro, like
|
|
264
264
|
|
|
265
265
|
```
|
|
266
266
|
Private Sub Worksheet_Calculate()
|
|
@@ -271,66 +271,34 @@ Private Sub Worksheet_Calculate()
|
|
|
271
271
|
End Sub
|
|
272
272
|
```
|
|
273
273
|
|
|
274
|
-
, where `MacroToExecute` should contain the user code, most likely code to decode
|
|
274
|
+
, where `MacroToExecute` should contain the user code, most likely code to decode file(s) encoded.
|
|
275
|
+
|
|
276
|
+
The repo contains a VBA module called xlwings_utils.bas with code to decode encoded files.
|
|
277
|
+
Just add the .bas file to a worksheet and call like
|
|
275
278
|
|
|
276
279
|
```
|
|
277
|
-
|
|
280
|
+
Sub MacroToExecute()
|
|
281
|
+
DecodeFile(Me, 10, 1)
|
|
278
282
|
```
|
|
283
|
+
|
|
284
|
+
In this example, the file *film1.mp4* will be downloaded into the current directory.
|
|
279
285
|
|
|
280
|
-
The
|
|
286
|
+
The module xlwings_utils also contains code to encode a local file to a sheet:
|
|
281
287
|
|
|
282
288
|
```
|
|
283
|
-
Sub
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
ThisDir = ThisWorkbook.Path
|
|
297
|
-
Set ws = Me
|
|
298
|
-
Count = 0
|
|
299
|
-
While Row < 30000
|
|
300
|
-
Line = ws.Cells(Row, Column)
|
|
301
|
-
If InStr(Line, "<file=") = 1 And Right(Line, 1) = ">" Then
|
|
302
|
-
If Count <> 0 Then
|
|
303
|
-
FileNames = FileNames & ", "
|
|
304
|
-
End If
|
|
305
|
-
Count = Count + 1
|
|
306
|
-
FileNameOnly = Mid(Line, 7, Len(Line) - 7)
|
|
307
|
-
Filename = ThisDir & "/" & FileNameOnly
|
|
308
|
-
FileNames = FileNames & FileNameOnly
|
|
309
|
-
|
|
310
|
-
Row = Row + 1
|
|
311
|
-
S = ""
|
|
312
|
-
While ws.Cells(Row, Column) <> "</file>"
|
|
313
|
-
S = S & ws.Cells(Row, Column)
|
|
314
|
-
Row = Row + 1
|
|
315
|
-
Wend
|
|
316
|
-
|
|
317
|
-
vArr = Base64ToArray(S)
|
|
318
|
-
|
|
319
|
-
Open Filename For Binary Access Write As #1
|
|
320
|
-
WritePos = 1
|
|
321
|
-
Put #1, WritePos, vArr
|
|
322
|
-
Close #1
|
|
323
|
-
End If
|
|
324
|
-
|
|
325
|
-
Row = Row + 1
|
|
326
|
-
|
|
327
|
-
Wend
|
|
328
|
-
|
|
329
|
-
If Count = 0 Then
|
|
330
|
-
MsgBox "No files to decode"
|
|
331
|
-
Else
|
|
332
|
-
MsgBox "Successfully decoded and written " & Str(Count) & " file(s): " & FileNames
|
|
333
|
-
End If
|
|
289
|
+
Sub MacroToExecute()
|
|
290
|
+
EncodeFile(Me, "data.json", 10, 1)
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
This will place an encoded version of *data.json* on the sheet.
|
|
294
|
+
|
|
295
|
+
Then, the file can be copied to the pyodide file system with
|
|
296
|
+
|
|
297
|
+
```
|
|
298
|
+
bl = block(xw.range((10,1),(50000,1)).decode_to_files())
|
|
299
|
+
```
|
|
300
|
+
```
|
|
301
|
+
|
|
334
302
|
```
|
|
335
303
|
|
|
336
304
|
## Contact info
|
|
@@ -179,24 +179,24 @@ def read_dropbox(dropbox_path, max_retries=100):
|
|
|
179
179
|
it is not necessary to call dropbox_init() prior to any dropbox function.
|
|
180
180
|
|
|
181
181
|
As reading from dropbox is very unreliable under pyodide, reading will have to be retried (by default maximum 100 times).
|
|
182
|
-
The number of retries can be found with read_dropbox.retries
|
|
182
|
+
The number of retries can be found with read_dropbox.retries.
|
|
183
183
|
"""
|
|
184
184
|
|
|
185
185
|
_login_dbx()
|
|
186
|
-
for read_dropbox.retries in range(max_retries+1):
|
|
186
|
+
for read_dropbox.retries in range(max_retries + 1):
|
|
187
187
|
metadata, response = dbx.files_download(dropbox_path)
|
|
188
188
|
file_content = response.content
|
|
189
189
|
if len(file_content) == metadata.size:
|
|
190
190
|
return file_content
|
|
191
191
|
raise OSError(f"after {max_retries} still no valid response")
|
|
192
192
|
|
|
193
|
+
|
|
193
194
|
def write_dropbox(dropbox_path, contents):
|
|
194
|
-
_login_dbx()
|
|
195
195
|
"""
|
|
196
196
|
write_dropbox
|
|
197
|
-
|
|
197
|
+
|
|
198
198
|
write from dopbox at given path
|
|
199
|
-
|
|
199
|
+
|
|
200
200
|
Parameters
|
|
201
201
|
----------
|
|
202
202
|
dropbox_path : str or Pathlib.Path
|
|
@@ -204,12 +204,13 @@ def write_dropbox(dropbox_path, contents):
|
|
|
204
204
|
|
|
205
205
|
contents : bytes
|
|
206
206
|
contents to be written
|
|
207
|
-
|
|
207
|
+
|
|
208
208
|
Note
|
|
209
209
|
----
|
|
210
210
|
If REFRESH_TOKEN, APP_KEY and APP_SECRET environment variables are specified,
|
|
211
211
|
it is not necessary to call dropbox_init() prior to any dropbox function.
|
|
212
212
|
"""
|
|
213
|
+
_login_dbx()
|
|
213
214
|
dbx.files_upload(contents, dropbox_path, mode=dropbox.files.WriteMode.overwrite)
|
|
214
215
|
|
|
215
216
|
|
|
@@ -433,6 +434,19 @@ class block:
|
|
|
433
434
|
if column > self.number_of_columns:
|
|
434
435
|
raise ValueError(f"{name}={column} > number_of_columns={self.number_of_columns}")
|
|
435
436
|
|
|
437
|
+
def transpose(self):
|
|
438
|
+
"""
|
|
439
|
+
transpose block
|
|
440
|
+
|
|
441
|
+
Returns
|
|
442
|
+
-------
|
|
443
|
+
transposed block : block
|
|
444
|
+
"""
|
|
445
|
+
bl = block(number_of_rows=self.number_of_columns, number_of_columns=self.number_of_rows)
|
|
446
|
+
for (row, column), value in self.dict.items():
|
|
447
|
+
bl[column, row] = value
|
|
448
|
+
return bl
|
|
449
|
+
|
|
436
450
|
def vlookup(self, s, *, row_from=1, row_to=missing, column1=1, column2=missing, default=missing):
|
|
437
451
|
"""
|
|
438
452
|
searches in column1 for row between row_from and row_to for s and returns the value found at (that row, column2)
|
|
@@ -685,57 +699,57 @@ class block:
|
|
|
685
699
|
|
|
686
700
|
def decode_to_files(self):
|
|
687
701
|
"""
|
|
688
|
-
decode the block with encoded file(s) to individual
|
|
702
|
+
decode the block with encoded file(s) to individual pyoidide files
|
|
689
703
|
"""
|
|
704
|
+
count = 0
|
|
690
705
|
for column in self.number_of_columns:
|
|
691
706
|
row = 1
|
|
707
|
+
bl = self.mimimized()
|
|
692
708
|
while row <= self.number_of_rows:
|
|
693
709
|
if self[row, column] and self[row, column].startswith("<file=") and self[row, column].endswith(">"):
|
|
694
710
|
filename = self[row, column][6:-1]
|
|
695
711
|
collect = []
|
|
696
712
|
row += 1
|
|
697
|
-
while
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
if self[row, column]:
|
|
701
|
-
collect.append(self[row, column])
|
|
713
|
+
while bl[row, column] != "</file>":
|
|
714
|
+
if bl[row, column]:
|
|
715
|
+
collect.append(bl[row, column])
|
|
702
716
|
row += 1
|
|
703
717
|
decoded = base64.b64decode("".join(collect))
|
|
704
718
|
open(filename, "wb").write(decoded)
|
|
719
|
+
count += 1
|
|
705
720
|
row += 1
|
|
721
|
+
return count
|
|
706
722
|
|
|
707
723
|
@classmethod
|
|
708
|
-
def
|
|
724
|
+
def encode_file(cls, file):
|
|
709
725
|
"""
|
|
710
|
-
make a block with the given
|
|
726
|
+
make a block with the given pyodide file encoded
|
|
711
727
|
|
|
712
728
|
Parameters
|
|
713
729
|
----------
|
|
714
|
-
|
|
715
|
-
|
|
730
|
+
file : file name (str)
|
|
731
|
+
file to be encoded
|
|
716
732
|
|
|
717
733
|
Returns
|
|
718
734
|
-------
|
|
719
|
-
block with encoded
|
|
720
|
-
not minimized!
|
|
735
|
+
block with encoded file : block (minimized)
|
|
721
736
|
"""
|
|
722
737
|
|
|
723
|
-
bl = cls(number_of_rows=
|
|
738
|
+
bl = cls(number_of_rows=100000, number_of_columns=1)
|
|
724
739
|
|
|
725
740
|
n = 5000 # block size
|
|
726
741
|
row = 1
|
|
727
|
-
|
|
728
|
-
|
|
742
|
+
bl[row, 1] = f"<file={file}>"
|
|
743
|
+
row += 1
|
|
744
|
+
b64 = base64.b64encode(open(file, "rb").read()).decode("utf-8")
|
|
745
|
+
while b64:
|
|
746
|
+
b64_n = b64[:n]
|
|
747
|
+
bl[row, 1] = b64_n
|
|
729
748
|
row += 1
|
|
730
|
-
b64 =
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
row += 1
|
|
735
|
-
b64 = b64[n:]
|
|
736
|
-
bl[row, 1] = f"</file>"
|
|
737
|
-
row += 1
|
|
738
|
-
return bl
|
|
749
|
+
b64 = b64[n:]
|
|
750
|
+
bl[row, 1] = f"</file>"
|
|
751
|
+
row += 1
|
|
752
|
+
return bl.minimized()
|
|
739
753
|
|
|
740
754
|
|
|
741
755
|
class Capture:
|
|
@@ -844,6 +858,7 @@ class Capture:
|
|
|
844
858
|
def include_print(self, value):
|
|
845
859
|
self._include_print = value
|
|
846
860
|
|
|
861
|
+
|
|
847
862
|
def trigger_macro(sheet):
|
|
848
863
|
"""
|
|
849
864
|
triggers the macro on sheet
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: xlwings_utils
|
|
3
|
-
Version: 25.0.6
|
|
3
|
+
Version: 25.0.6.post0
|
|
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
|
|
@@ -62,7 +62,7 @@ python -c "exec(__import__('requests').get('https://salabim.org/dropbox setup.py
|
|
|
62
62
|
Then, it is possible to list all files in a specified folder using the list_dropbox function.
|
|
63
63
|
It is also possible to get the folders and to access all underlying folders.
|
|
64
64
|
|
|
65
|
-
The `read_dropbox` function can be used to read the contents (bytes) of a Dropbox file. As reading from Dropbox under pyodide is
|
|
65
|
+
The `read_dropbox` function can be used to read the contents (bytes) of a Dropbox file. As reading from Dropbox under pyodide is rather unreliable, xlwings_utils automatically retries several times (by default 100 times). The actual number of retries can be found with `read_dropbox.retries`.
|
|
66
66
|
|
|
67
67
|
The function `write_dropbox` can be used to write contents (bytes) to a Dropbox file.
|
|
68
68
|
|
|
@@ -269,11 +269,11 @@ Currently, *xlwings Lite* does not provide access to the local file system. Ther
|
|
|
269
269
|
Files can be encoded into a block, like:
|
|
270
270
|
|
|
271
271
|
```
|
|
272
|
-
bl = xwu.block.
|
|
273
|
-
book.sheets["VBA"].range((10,
|
|
272
|
+
bl = xwu.block.encode_file("film1.mp4")
|
|
273
|
+
book.sheets["VBA"].range((10,1)).value=bl.value
|
|
274
274
|
```
|
|
275
275
|
|
|
276
|
-
With this code, column
|
|
276
|
+
With this code, column A will be filled with an encoded copy of the files *film1.mp4* . This can then be used with a suitable VBA macro to decode to the real file system. A VBA macro can be triggered with `xwu.trigger_macro()`. This requires an Excel worksheet where cell A1 is reserved for communication with xlwings lite. This worksheet needs to contain a macro, like
|
|
277
277
|
|
|
278
278
|
```
|
|
279
279
|
Private Sub Worksheet_Calculate()
|
|
@@ -284,66 +284,34 @@ Private Sub Worksheet_Calculate()
|
|
|
284
284
|
End Sub
|
|
285
285
|
```
|
|
286
286
|
|
|
287
|
-
, where `MacroToExecute` should contain the user code, most likely code to decode
|
|
287
|
+
, where `MacroToExecute` should contain the user code, most likely code to decode file(s) encoded.
|
|
288
|
+
|
|
289
|
+
The repo contains a VBA module called xlwings_utils.bas with code to decode encoded files.
|
|
290
|
+
Just add the .bas file to a worksheet and call like
|
|
288
291
|
|
|
289
292
|
```
|
|
290
|
-
|
|
293
|
+
Sub MacroToExecute()
|
|
294
|
+
DecodeFile(Me, 10, 1)
|
|
291
295
|
```
|
|
296
|
+
|
|
297
|
+
In this example, the file *film1.mp4* will be downloaded into the current directory.
|
|
292
298
|
|
|
293
|
-
The
|
|
299
|
+
The module xlwings_utils also contains code to encode a local file to a sheet:
|
|
294
300
|
|
|
295
301
|
```
|
|
296
|
-
Sub
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
ThisDir = ThisWorkbook.Path
|
|
310
|
-
Set ws = Me
|
|
311
|
-
Count = 0
|
|
312
|
-
While Row < 30000
|
|
313
|
-
Line = ws.Cells(Row, Column)
|
|
314
|
-
If InStr(Line, "<file=") = 1 And Right(Line, 1) = ">" Then
|
|
315
|
-
If Count <> 0 Then
|
|
316
|
-
FileNames = FileNames & ", "
|
|
317
|
-
End If
|
|
318
|
-
Count = Count + 1
|
|
319
|
-
FileNameOnly = Mid(Line, 7, Len(Line) - 7)
|
|
320
|
-
Filename = ThisDir & "/" & FileNameOnly
|
|
321
|
-
FileNames = FileNames & FileNameOnly
|
|
322
|
-
|
|
323
|
-
Row = Row + 1
|
|
324
|
-
S = ""
|
|
325
|
-
While ws.Cells(Row, Column) <> "</file>"
|
|
326
|
-
S = S & ws.Cells(Row, Column)
|
|
327
|
-
Row = Row + 1
|
|
328
|
-
Wend
|
|
329
|
-
|
|
330
|
-
vArr = Base64ToArray(S)
|
|
331
|
-
|
|
332
|
-
Open Filename For Binary Access Write As #1
|
|
333
|
-
WritePos = 1
|
|
334
|
-
Put #1, WritePos, vArr
|
|
335
|
-
Close #1
|
|
336
|
-
End If
|
|
337
|
-
|
|
338
|
-
Row = Row + 1
|
|
339
|
-
|
|
340
|
-
Wend
|
|
341
|
-
|
|
342
|
-
If Count = 0 Then
|
|
343
|
-
MsgBox "No files to decode"
|
|
344
|
-
Else
|
|
345
|
-
MsgBox "Successfully decoded and written " & Str(Count) & " file(s): " & FileNames
|
|
346
|
-
End If
|
|
302
|
+
Sub MacroToExecute()
|
|
303
|
+
EncodeFile(Me, "data.json", 10, 1)
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
This will place an encoded version of *data.json* on the sheet.
|
|
307
|
+
|
|
308
|
+
Then, the file can be copied to the pyodide file system with
|
|
309
|
+
|
|
310
|
+
```
|
|
311
|
+
bl = block(xw.range((10,1),(50000,1)).decode_to_files())
|
|
312
|
+
```
|
|
313
|
+
```
|
|
314
|
+
|
|
347
315
|
```
|
|
348
316
|
|
|
349
317
|
## Contact info
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{xlwings_utils-25.0.6 → xlwings_utils-25.0.6.post0}/xlwings_utils.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|