xlwings-utils 25.0.4__py3-none-any.whl → 25.0.5__py3-none-any.whl

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.

@@ -5,7 +5,7 @@
5
5
  # /_/\_\|_| \_/\_/ |_||_| |_| \__, ||___/ _____ \__,_| \__||_||_||___/
6
6
  # |___/ |_____|
7
7
 
8
- __version__ = "25.0.4"
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.4
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
- It is only possible, as of now, to use full-access Dropbox apps.
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 to manipulate a range without accessing the range directly, which is expensive in terms of memory and execution time.
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 that they are one-based, just like in Excel.
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 make a block from a pandas dataframe with `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)`.
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 van be enabled and disabled at any time with `capture.enbaled = True` and `capture.enabled = False`.
238
+ Capturing can be enabled and disabled at any time with `capture.enabled = True` and `capture.enabled = False`.
239
239
 
240
- And including print likewise with `capture.include_print`.
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 then copied to a sheet, like
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
@@ -0,0 +1,6 @@
1
+ xlwings_utils/__init__.py,sha256=FdaRztevSu5akGL7KBUBRzqwLMRTdvVUuS2Kfp2f1Uc,68
2
+ xlwings_utils/xlwings_utils.py,sha256=LT2NxlvS0T9wY4Qi9UiINpS1S1nmM2IutoBgkWk3JDo,24760
3
+ xlwings_utils-25.0.5.dist-info/METADATA,sha256=MBHmRPFi-ytcOioOS2oII7pWN9e6SyOXHV_M3CVSJBs,10317
4
+ xlwings_utils-25.0.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
5
+ xlwings_utils-25.0.5.dist-info/top_level.txt,sha256=kf5SEv0gZiRObPhUoYcc1O_iX_wwTOPeUIYvzyYeAM4,14
6
+ xlwings_utils-25.0.5.dist-info/RECORD,,
@@ -1,6 +0,0 @@
1
- xlwings_utils/__init__.py,sha256=FdaRztevSu5akGL7KBUBRzqwLMRTdvVUuS2Kfp2f1Uc,68
2
- xlwings_utils/xlwings_utils.py,sha256=LF7niTS7WnNSoJunwuhF5OYP7yVsLK70Zt59lY0SbMs,23376
3
- xlwings_utils-25.0.4.dist-info/METADATA,sha256=4pWOuXUtYWkBq4rEEDxIkmITWVECrMzh-PxdlpQ-SXc,10286
4
- xlwings_utils-25.0.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
5
- xlwings_utils-25.0.4.dist-info/top_level.txt,sha256=kf5SEv0gZiRObPhUoYcc1O_iX_wwTOPeUIYvzyYeAM4,14
6
- xlwings_utils-25.0.4.dist-info/RECORD,,