xlwings-utils 25.0.5__tar.gz → 25.0.5.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.5/xlwings_utils.egg-info → xlwings_utils-25.0.5.post0}/PKG-INFO +85 -2
- xlwings_utils-25.0.5/PKG-INFO → xlwings_utils-25.0.5.post0/README.md +346 -276
- {xlwings_utils-25.0.5 → xlwings_utils-25.0.5.post0}/pyproject.toml +1 -1
- {xlwings_utils-25.0.5 → xlwings_utils-25.0.5.post0}/xlwings_utils/xlwings_utils.py +65 -58
- xlwings_utils-25.0.5/README.md → xlwings_utils-25.0.5.post0/xlwings_utils.egg-info/PKG-INFO +359 -263
- {xlwings_utils-25.0.5 → xlwings_utils-25.0.5.post0}/setup.cfg +0 -0
- {xlwings_utils-25.0.5 → xlwings_utils-25.0.5.post0}/tests/test_xlwings_utils.py +0 -0
- {xlwings_utils-25.0.5 → xlwings_utils-25.0.5.post0}/xlwings_utils/__init__.py +0 -0
- {xlwings_utils-25.0.5 → xlwings_utils-25.0.5.post0}/xlwings_utils.egg-info/SOURCES.txt +0 -0
- {xlwings_utils-25.0.5 → xlwings_utils-25.0.5.post0}/xlwings_utils.egg-info/dependency_links.txt +0 -0
- {xlwings_utils-25.0.5 → xlwings_utils-25.0.5.post0}/xlwings_utils.egg-info/requires.txt +0 -0
- {xlwings_utils-25.0.5 → xlwings_utils-25.0.5.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.5
|
|
3
|
+
Version: 25.0.5.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
|
|
@@ -263,10 +263,93 @@ The capture buffer can also be retrieved as a string with `capture.str` and `cap
|
|
|
263
263
|
|
|
264
264
|
Clearing the captured stdout buffer can be done at any time with `capture.clear()`.
|
|
265
265
|
|
|
266
|
+
## Functionality for accessing local files via VBA
|
|
267
|
+
|
|
268
|
+
Currently, *xlwings Lite* does not provide access to the local file system. Therefore, xlwings_utils offers some functionality to trigger a VBA script as well as functionality to encode a file in the pyodide file system to a VBA sheet and to trigger writing the encoded file(s) to the local file system.
|
|
269
|
+
|
|
270
|
+
Note that the sheet must have a worksheet named `VBA`, and the VBA code will normally reside there.
|
|
271
|
+
|
|
272
|
+
There are three Python functions defined:
|
|
273
|
+
|
|
274
|
+
* `trigger_VBA()`
|
|
275
|
+
fires a VBA script, provided a VBA function is defined on the sheet, like:
|
|
276
|
+
|
|
277
|
+
```
|
|
278
|
+
Sub Worksheet_Calculate()
|
|
279
|
+
If Me.Range("A1").Formula = "=NOW()" Then
|
|
280
|
+
Me.Range("A1").Value = Null
|
|
281
|
+
REM Code to run
|
|
282
|
+
End If
|
|
283
|
+
End Sub
|
|
284
|
+
```
|
|
285
|
+
* `init_transfer_files()`
|
|
286
|
+
This should be called prior to any `transfer_file` call. It just removes all encoded files from the VBA sheet (if any)
|
|
287
|
+
|
|
288
|
+
* `transfer_file()`
|
|
289
|
+
Can be used to encode a file on the pyodide file system to the VBA sheet. Multiple files are allowed. The file name will be encoded on the sheet as well.
|
|
290
|
+
|
|
291
|
+
The VBA code below can be used to decode encoded file(s) and write to the local file system.
|
|
292
|
+
|
|
293
|
+
```
|
|
294
|
+
Sub WriteFiles()
|
|
295
|
+
|
|
296
|
+
Dim vArr() As Byte
|
|
297
|
+
Dim S As String
|
|
298
|
+
Dim Column As Integer
|
|
299
|
+
Dim Row As Integer
|
|
300
|
+
Dim ws As Worksheet
|
|
301
|
+
Dim Count As Integer
|
|
302
|
+
Dim FileNames As String
|
|
303
|
+
|
|
304
|
+
Column = 1
|
|
305
|
+
Row = 1
|
|
306
|
+
|
|
307
|
+
ThisDir = ThisWorkbook.Path
|
|
308
|
+
Set ws = Me
|
|
309
|
+
Count = 0
|
|
310
|
+
While Row < 30000
|
|
311
|
+
Line = ws.Cells(Row, Column)
|
|
312
|
+
If InStr(Line, "<file=") = 1 And Right(Line, 1) = ">" Then
|
|
313
|
+
If Count <> 0 Then
|
|
314
|
+
FileNames = FileNames & ", "
|
|
315
|
+
End If
|
|
316
|
+
Count = Count + 1
|
|
317
|
+
FileNameOnly = Mid(Line, 7, Len(Line) - 7)
|
|
318
|
+
Filename = ThisDir & "/" & FileNameOnly
|
|
319
|
+
FileNames = FileNames & FileNameOnly
|
|
320
|
+
|
|
321
|
+
Row = Row + 1
|
|
322
|
+
S = ""
|
|
323
|
+
While ws.Cells(Row, Column) <> "</file>"
|
|
324
|
+
S = S & ws.Cells(Row, Column)
|
|
325
|
+
Row = Row + 1
|
|
326
|
+
Wend
|
|
327
|
+
|
|
328
|
+
vArr = Base64ToArray(S)
|
|
329
|
+
|
|
330
|
+
Open Filename For Binary Access Write As #1
|
|
331
|
+
WritePos = 1
|
|
332
|
+
Put #1, WritePos, vArr
|
|
333
|
+
Close #1
|
|
334
|
+
End If
|
|
335
|
+
|
|
336
|
+
Row = Row + 1
|
|
337
|
+
|
|
338
|
+
Wend
|
|
339
|
+
If Cells(4, 2) = "y" Then
|
|
340
|
+
ws.Range("A10:A1000000").Clear
|
|
341
|
+
End If
|
|
342
|
+
|
|
343
|
+
If Count = 0 Then
|
|
344
|
+
MsgBox "No files written"
|
|
345
|
+
Else
|
|
346
|
+
MsgBox "Successfully written " & Str(Count) & " file(s): " & FileNames
|
|
347
|
+
End If
|
|
348
|
+
```
|
|
266
349
|
|
|
267
350
|
## Contact info
|
|
268
351
|
|
|
269
|
-
You can contact Ruud van der Ham, the core developer,
|
|
352
|
+
You can contact Ruud van der Ham, the core developer, at ruud@salabim.org.
|
|
270
353
|
|
|
271
354
|
## Badges
|
|
272
355
|
|