-
Notifications
You must be signed in to change notification settings - Fork 1
/
LibreOfficeCalc_Range.au3
5666 lines (4770 loc) · 357 KB
/
LibreOfficeCalc_Range.au3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
;~ #Tidy_Parameters=/sf
#include-once
; Main LibreOffice Includes
#include "LibreOffice_Constants.au3"
; Common includes for Calc
#include "LibreOfficeCalc_Internal.au3"
; Other includes for Calc
; #INDEX# =======================================================================================================================
; Title .........: LibreOffice UDF
; AutoIt Version : v3.3.16.1
; Description ...: Provides basic functionality through AutoIt for Creating, Modifying, or applying settings to L.O. Calc Cell Ranges.
; Author(s) .....: donnyh13, mLipok
; Dll ...........:
;
; ===============================================================================================================================
; #CURRENT# =====================================================================================================================
; _LOCalc_RangeAutoOutline
; _LOCalc_RangeClearContents
; _LOCalc_RangeColumnDelete
; _LOCalc_RangeColumnGetName
; _LOCalc_RangeColumnGetObjByName
; _LOCalc_RangeColumnGetObjByPosition
; _LOCalc_RangeColumnInsert
; _LOCalc_RangeColumnPageBreak
; _LOCalc_RangeColumnsGetCount
; _LOCalc_RangeColumnVisible
; _LOCalc_RangeColumnWidth
; _LOCalc_RangeCompute
; _LOCalc_RangeCopyMove
; _LOCalc_RangeCreateCursor
; _LOCalc_RangeData
; _LOCalc_RangeDatabaseAdd
; _LOCalc_RangeDatabaseDelete
; _LOCalc_RangeDatabaseExists
; _LOCalc_RangeDatabaseGetNames
; _LOCalc_RangeDatabaseGetObjByName
; _LOCalc_RangeDatabaseModify
; _LOCalc_RangeDelete
; _LOCalc_RangeDetail
; _LOCalc_RangeFill
; _LOCalc_RangeFillSeries
; _LOCalc_RangeFilter
; _LOCalc_RangeFilterAdvanced
; _LOCalc_RangeFilterClear
; _LOCalc_RangeFindAll
; _LOCalc_RangeFindNext
; _LOCalc_RangeFormula
; _LOCalc_RangeGetAddressAsName
; _LOCalc_RangeGetAddressAsPosition
; _LOCalc_RangeGetCellByName
; _LOCalc_RangeGetCellByPosition
; _LOCalc_RangeGetSheet
; _LOCalc_RangeGroup
; _LOCalc_RangeInsert
; _LOCalc_RangeIsMerged
; _LOCalc_RangeMerge
; _LOCalc_RangeNamedAdd
; _LOCalc_RangeNamedChangeScope
; _LOCalc_RangeNamedDelete
; _LOCalc_RangeNamedExists
; _LOCalc_RangeNamedGetNames
; _LOCalc_RangeNamedGetObjByName
; _LOCalc_RangeNamedModify
; _LOCalc_RangeNumbers
; _LOCalc_RangeOutlineClearAll
; _LOCalc_RangeOutlineShow
; _LOCalc_RangePivotDelete
; _LOCalc_RangePivotDest
; _LOCalc_RangePivotExists
; _LOCalc_RangePivotFieldGetObjByName
; _LOCalc_RangePivotFieldItemsGetNames
; _LOCalc_RangePivotFieldsColumnsGetNames
; _LOCalc_RangePivotFieldsDataGetNames
; _LOCalc_RangePivotFieldSettings
; _LOCalc_RangePivotFieldsFiltersGetNames
; _LOCalc_RangePivotFieldsGetNames
; _LOCalc_RangePivotFieldsRowsGetNames
; _LOCalc_RangePivotFieldsUnusedGetNames
; _LOCalc_RangePivotFilter
; _LOCalc_RangePivotFilterClear
; _LOCalc_RangePivotGetObjByIndex
; _LOCalc_RangePivotGetObjByName
; _LOCalc_RangePivotInsert
; _LOCalc_RangePivotName
; _LOCalc_RangePivotRefresh
; _LOCalc_RangePivotSettings
; _LOCalc_RangePivotsGetCount
; _LOCalc_RangePivotsGetNames
; _LOCalc_RangePivotSource
; _LOCalc_RangeQueryColumnDiff
; _LOCalc_RangeQueryContents
; _LOCalc_RangeQueryDependents
; _LOCalc_RangeQueryEmpty
; _LOCalc_RangeQueryFormula
; _LOCalc_RangeQueryIntersection
; _LOCalc_RangeQueryPrecedents
; _LOCalc_RangeQueryRowDiff
; _LOCalc_RangeQueryVisible
; _LOCalc_RangeReplace
; _LOCalc_RangeReplaceAll
; _LOCalc_RangeRowDelete
; _LOCalc_RangeRowGetObjByPosition
; _LOCalc_RangeRowHeight
; _LOCalc_RangeRowInsert
; _LOCalc_RangeRowPageBreak
; _LOCalc_RangeRowsGetCount
; _LOCalc_RangeRowVisible
; _LOCalc_RangeSort
; _LOCalc_RangeSortAlt
; _LOCalc_RangeValidation
; _LOCalc_RangeValidationSettings
; ===============================================================================================================================
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOCalc_RangeAutoOutline
; Description ...: Set up AutoOutline for a Range of Cells.
; Syntax ........: _LOCalc_RangeAutoOutline(ByRef $oRange)
; Parameters ....: $oRange - [in/out] an object. A Cell Range or Cell object returned by a previous _LOCalc_RangeGetCellByName, _LOCalc_RangeGetCellByPosition, _LOCalc_RangeColumnGetObjByPosition, _LOCalc_RangeColumnGetObjByName, _LOcalc_RangeRowGetObjByPosition, _LOCalc_SheetGetObjByName, or _LOCalc_SheetGetActive function.
; Return values .: Success: 1
; Failure: 0 and sets the @Error and @Extended flags to non-zero.
; --Input Errors--
; @Error 1 @Extended 1 Return 0 = $oRange not an Object.
; --Processing Errors--
; @Error 3 @Extended 1 Return 0 = Failed to retrieve Range Address Structure.
; --Success--
; @Error 0 @Extended 0 Return 1 = Success. AutoOutline was successfully processed for range.
; Author ........: donnyh13
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOCalc_RangeAutoOutline(ByRef $oRange)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOCalc_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $tRangeAddress
If Not IsObj($oRange) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
$tRangeAddress = $oRange.RangeAddress()
If Not IsObj($tRangeAddress) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 1, 0)
$oRange.Spreadsheet.autoOutline($tRangeAddress)
Return SetError($__LO_STATUS_SUCCESS, 0, 1)
EndFunc ;==>_LOCalc_RangeAutoOutline
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOCalc_RangeClearContents
; Description ...: Clear specific cell contents in a range.
; Syntax ........: _LOCalc_RangeClearContents(ByRef $oRange, $iFlags)
; Parameters ....: $oRange - [in/out] an object. A Cell Range or Cell to clear the contents of. A Cell Range or Cell object returned by a previous _LOCalc_RangeGetCellByName, _LOCalc_RangeGetCellByPosition, _LOCalc_RangeColumnGetObjByPosition, _LOCalc_RangeColumnGetObjByName, _LOcalc_RangeRowGetObjByPosition, _LOCalc_SheetGetObjByName, or _LOCalc_SheetGetActive function.
; $iFlags - an integer value (1-1023). The Cell Content type to delete. Can be BitOR'd together. See Constants $LOC_CELL_FLAG_* as defined in LibreOfficeCalc_Constants.au3
; Return values .: Success: 1
; Failure: 0 and sets the @Error and @Extended flags to non-zero.
; --Input Errors--
; @Error 1 @Extended 1 Return 0 = $oRange not an Object.
; @Error 1 @Extended 2 Return 0 = $iFlags not an Integer, less than 1, or greater than 1023. See Constants $LOC_CELL_FLAG_* as defined in LibreOfficeCalc_Constants.au3.
; --Success--
; @Error 0 @Extended 0 Return 1 = Success. Contents specified was successfully cleared from the cell range.
; Author ........: donnyh13
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOCalc_RangeClearContents(ByRef $oRange, $iFlags)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOCalc_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
If Not IsObj($oRange) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If Not __LOCalc_IntIsBetween($iFlags, $LOC_CELL_FLAG_VALUE, $LOC_CELL_FLAG_ALL) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
$oRange.clearContents($iFlags)
Return SetError($__LO_STATUS_SUCCESS, 0, 1)
EndFunc ;==>_LOCalc_RangeClearContents
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOCalc_RangeColumnDelete
; Description ...: Delete Columns from a Range.
; Syntax ........: _LOCalc_RangeColumnDelete(ByRef $oRange, $iColumn[, $iCount = 1])
; Parameters ....: $oRange - [in/out] an object. A Cell Range or Cell object returned by a previous _LOCalc_RangeGetCellByName, _LOCalc_RangeGetCellByPosition, _LOCalc_RangeColumnGetObjByPosition, _LOCalc_RangeColumnGetObjByName, _LOcalc_RangeRowGetObjByPosition, _LOCalc_SheetGetObjByName, or _LOCalc_SheetGetActive function.
; $iColumn - an integer value. The column to begin deleting at. The Column called will be deleted. See remarks.
; $iCount - [optional] an integer value. Default is 1. The number of columns to delete after the called column.
; Return values .: Success: 1
; Failure: 0 and sets the @Error and @Extended flags to non-zero.
; --Input Errors--
; @Error 1 @Extended 1 Return 0 = $oRange not an Object.
; @Error 1 @Extended 2 Return 0 = $iColumns not an Integer or less than 0, or greater than number of Columns contained in the Range.
; @Error 1 @Extended 3 Return 0 = $iCount not an Integer, or less than 1.
; --Processing Errors--
; @Error 3 @Extended 1 Return 0 = Failed to retrieve Columns Object.
; --Success--
; @Error 0 @Extended 0 Return 1 = Success. Successfully deleted requested columns.
; Author ........: donnyh13
; Modified ......:
; Remarks .......: Columns in L.O. Calc are 0 based, to Delete Column "A" in the LibreOffice UI, you would call $iColumn with 0.
; Deleting Columns does not decrease the Column count, it simply erases the Column's contents in a specific area and shifts all after content left.
; Related .......: _LOCalc_RangeColumnInsert
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOCalc_RangeColumnDelete(ByRef $oRange, $iColumn, $iCount = 1)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOCalc_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $oColumns
If Not IsObj($oRange) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
$oColumns = $oRange.getColumns()
If Not IsObj($oColumns) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 1, 0)
If Not __LOCalc_IntIsBetween($iColumn, 0, $oColumns.Count() - 1) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
If Not __LOCalc_IntIsBetween($iCount, 1) Then Return SetError($__LO_STATUS_INPUT_ERROR, 3, 0)
$oColumns.removeByIndex($iColumn, $iCount)
Return SetError($__LO_STATUS_SUCCESS, 0, 1)
EndFunc ;==>_LOCalc_RangeColumnDelete
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOCalc_RangeColumnGetName
; Description ...: Retrieve the Column's name.
; Syntax ........: _LOCalc_RangeColumnGetName(ByRef $oColumn)
; Parameters ....: $oColumn - [in/out] an object. A Column object returned by a previous _LOCalc_RangeColumnGetObjByPosition, or _LOCalc_RangeColumnGetObjByName function.
; Return values .: Success: String
; Failure: 0 and sets the @Error and @Extended flags to non-zero.
; --Input Errors--
; @Error 1 @Extended 1 Return 0 = $oColumn not an Object.
; --Processing Errors--
; @Error 3 @Extended 1 Return 0 = Failed to retrieve the Column's name.
; --Success--
; @Error 0 @Extended 0 Return String = Success. Success, returning Column's name.
; Author ........: donnyh13
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOCalc_RangeColumnGetName(ByRef $oColumn)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOCalc_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $sName
If Not IsObj($oColumn) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
$sName = $oColumn.Name()
If Not IsString($sName) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 1, 0)
Return SetError($__LO_STATUS_SUCCESS, 0, $sName)
EndFunc ;==>_LOCalc_RangeColumnGetName
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOCalc_RangeColumnGetObjByName
; Description ...: Retrieve a Column's Object by name.
; Syntax ........: _LOCalc_RangeColumnGetObjByName(ByRef $oRange, $sName)
; Parameters ....: $oRange - [in/out] an object. A Cell Range or Cell object returned by a previous _LOCalc_RangeGetCellByName, _LOCalc_RangeGetCellByPosition, _LOCalc_RangeColumnGetObjByPosition, _LOCalc_RangeColumnGetObjByName, _LOcalc_RangeRowGetObjByPosition, _LOCalc_SheetGetObjByName, or _LOCalc_SheetGetActive function.
; $sName - a string value. The Column name to retrieve the Object for, such as "A".
; Return values .: Success: Object
; Failure: 0 and sets the @Error and @Extended flags to non-zero.
; --Input Errors--
; @Error 1 @Extended 1 Return 0 = $oRange not an Object.
; @Error 1 @Extended 2 Return 0 = $sName not a String.
; @Error 1 @Extended 3 Return 0 = Range does not contain a column with name called in $sName.
; --Processing Errors--
; @Error 3 @Extended 1 Return 0 = Failed to retrieve Columns Object.
; @Error 3 @Extended 2 Return 0 = Failed to retrieve Column Object.
; --Success--
; @Error 0 @Extended 0 Return Object = Success. Success, returning Column's Object.
; Author ........: donnyh13
; Modified ......:
; Remarks .......:
; Related .......: _LOCalc_RangeColumnGetObjByPosition
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOCalc_RangeColumnGetObjByName(ByRef $oRange, $sName)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOCalc_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $oColumns, $oColumn
If Not IsObj($oRange) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If Not IsString($sName) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
$oColumns = $oRange.getColumns()
If Not IsObj($oColumns) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 1, 0)
If Not $oColumns.hasByName($sName) Then Return SetError($__LO_STATUS_INPUT_ERROR, 3, 0)
$oColumn = $oColumns.getByName($sName)
If Not IsObj($oColumn) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 2, 0)
Return SetError($__LO_STATUS_SUCCESS, 0, $oColumn)
EndFunc ;==>_LOCalc_RangeColumnGetObjByName
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOCalc_RangeColumnGetObjByPosition
; Description ...: Retrieve the Column's Object by its position.
; Syntax ........: _LOCalc_RangeColumnGetObjByPosition(ByRef $oRange, $iColumn)
; Parameters ....: $oRange - [in/out] an object. A Cell Range or Cell object returned by a previous _LOCalc_RangeGetCellByName, _LOCalc_RangeGetCellByPosition, _LOCalc_RangeColumnGetObjByPosition, _LOCalc_RangeColumnGetObjByName, _LOcalc_RangeRowGetObjByPosition, _LOCalc_SheetGetObjByName, or _LOCalc_SheetGetActive function.
; $iColumn - an integer value. The Column number to retrieve the Object for. See remarks.
; Return values .: Success: Object
; Failure: 0 and sets the @Error and @Extended flags to non-zero.
; --Input Errors--
; @Error 1 @Extended 1 Return 0 = $oRange not an Object.
; @Error 1 @Extended 2 Return 0 = $iColumn not an Integer, or less than 0, or greater than number of columns contained in the Range.
; --Processing Errors--
; @Error 3 @Extended 1 Return 0 = Failed to retrieve Columns Object.
; @Error 3 @Extended 2 Return 0 = Failed to retrieve Column Object.
; --Success--
; @Error 0 @Extended 0 Return Object = Success. Success, returning Column's Object.
; Author ........: donnyh13
; Modified ......:
; Remarks .......: Columns in L.O. Calc are 0 based, to retrieve Column "A" in the LibreOffice UI, you would call $iColumn with 0.
; Related .......: _LOCalc_RangeColumnGetObjByName
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOCalc_RangeColumnGetObjByPosition(ByRef $oRange, $iColumn)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOCalc_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $oColumns, $oColumn
If Not IsObj($oRange) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
$oColumns = $oRange.getColumns()
If Not IsObj($oColumns) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 1, 0)
If Not __LOCalc_IntIsBetween($iColumn, 0, $oColumns.Count() - 1) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
$oColumn = $oColumns.getByIndex($iColumn)
If Not IsObj($oColumn) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 2, 0)
Return SetError($__LO_STATUS_SUCCESS, 0, $oColumn)
EndFunc ;==>_LOCalc_RangeColumnGetObjByPosition
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOCalc_RangeColumnInsert
; Description ...: Insert blank columns into a Range at a specific column.
; Syntax ........: _LOCalc_RangeColumnInsert(ByRef $oRange, $iColumn[, $iCount = 1])
; Parameters ....: $oRange - [in/out] an object. A Cell Range or Cell object returned by a previous _LOCalc_RangeGetCellByName, _LOCalc_RangeGetCellByPosition, _LOCalc_RangeColumnGetObjByPosition, _LOCalc_RangeColumnGetObjByName, _LOcalc_RangeRowGetObjByPosition, _LOCalc_SheetGetObjByName, or _LOCalc_SheetGetActive function.
; $iColumn - an integer value. The Column to insert the new column(s) at. See remarks. New columns will be inserted starting at this column and all content will be shifted right.
; $iCount - [optional] an integer value. Default is 1. The number of blank columns to insert after the Column called.
; Return values .: Success: 1
; Failure: 0 and sets the @Error and @Extended flags to non-zero.
; --Input Errors--
; @Error 1 @Extended 1 Return 0 = $oRange not an Object.
; @Error 1 @Extended 2 Return 0 = $iColumn not an Integer or less than 0, or greater than number of Columns contained in the Range.
; @Error 1 @Extended 3 Return 0 = $iCount not an Integer, or less than 1.
; --Processing Errors--
; @Error 3 @Extended 1 Return 0 = Failed to retrieve Columns Object.
; --Success--
; @Error 0 @Extended 0 Return 1 = Success. Successfully inserted blank columns.
; Author ........: donnyh13
; Modified ......:
; Remarks .......: Columns in L.O. Calc are 0 based, to add columns in Column "A" in the LibreOffice UI, you would call $iColumn with 0.
; Inserting Columns does not increase the Column count, it simply adds blanks in a specific area and shifts all after content further right.
; Related .......: _LOCalc_RangeColumnDelete
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOCalc_RangeColumnInsert(ByRef $oRange, $iColumn, $iCount = 1)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOCalc_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $oColumns
If Not IsObj($oRange) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
$oColumns = $oRange.getColumns()
If Not IsObj($oColumns) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 1, 0)
If Not __LOCalc_IntIsBetween($iColumn, 0, $oColumns.Count()) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
If Not __LOCalc_IntIsBetween($iCount, 1) Then Return SetError($__LO_STATUS_INPUT_ERROR, 3, 0)
$oColumns.insertByIndex($iColumn, $iCount)
Return SetError($__LO_STATUS_SUCCESS, 0, 1)
EndFunc ;==>_LOCalc_RangeColumnInsert
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOCalc_RangeColumnPageBreak
; Description ...: Set or retrieve Page Break settings for a Column.
; Syntax ........: _LOCalc_RangeColumnPageBreak(ByRef $oColumn[, $bManualPageBreak = Null[, $bStartOfPageBreak = Null]])
; Parameters ....: $oColumn - [in/out] an object. A Column object returned by a previous _LOCalc_RangeColumnGetObjByPosition, or _LOCalc_RangeColumnGetObjByName function.
; $bManualPageBreak - [optional] a boolean value. Default is Null. If True, this column is the beginning of a manual Page Break.
; $bStartOfPageBreak - [optional] a boolean value. Default is Null. If True, this column is the beginning of a start of Page Break. See Remarks.
; Return values .: Success: 1 or Array
; Failure: 0 and sets the @Error and @Extended flags to non-zero.
; --Input Errors--
; @Error 1 @Extended 1 Return 0 = $oColumn not an Object.
; @Error 1 @Extended 2 Return 0 = $bManualPageBreak not a Boolean.
; @Error 1 @Extended 3 Return 0 = $bStartOfPageBreak not a Boolean.
; --Property Setting Errors--
; @Error 4 @Extended ? Return 0 = Some settings were not successfully set. Use BitAND to test @Extended for following values:
; | 1 = Error setting $bManualPageBreak
; | 2 = Error setting $bStartOfPageBreak
; --Success--
; @Error 0 @Extended 0 Return 1 = Success. Settings were successfully set.
; @Error 0 @Extended 1 Return Array = Success. All optional parameters were set to Null, returning current settings in a 2 Element Array with values in order of function parameters.
; Author ........: donnyh13
; Modified ......:
; Remarks .......: Setting $bStartOfPageBreak to True will insert a Manual Page Break, the same as setting $bManualPageBreak to True would.
; $bStartOfPageBreak setting is available more for indicating where Calc is inserting Page Breaks rather than for applying a setting. You can retrieve the settings for each Column, and check if this value is set to True or not. If the Page break is an automatically inserted one, the value for $bManualPageBreak would be false.
; Call this function with only the required parameters (or with all other parameters set to Null keyword), to get the current settings.
; Call any optional parameter with Null keyword to skip it.
; Related .......:
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOCalc_RangeColumnPageBreak(ByRef $oColumn, $bManualPageBreak = Null, $bStartOfPageBreak = Null)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOCalc_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $iError = 0
Local $abBreak[2]
If Not IsObj($oColumn) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If __LOCalc_VarsAreNull($bManualPageBreak, $bStartOfPageBreak) Then
__LOCalc_ArrayFill($abBreak, $oColumn.IsManualPageBreak(), $oColumn.IsStartOfNewPage())
Return SetError($__LO_STATUS_SUCCESS, 1, $abBreak)
EndIf
If ($bManualPageBreak <> Null) Then
If Not IsBool($bManualPageBreak) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
$oColumn.IsManualPageBreak = $bManualPageBreak
$iError = ($oColumn.IsManualPageBreak() = $bManualPageBreak) ? ($iError) : (BitOR($iError, 1))
EndIf
If ($bStartOfPageBreak <> Null) Then
If Not IsBool($bStartOfPageBreak) Then Return SetError($__LO_STATUS_INPUT_ERROR, 3, 0)
$oColumn.IsStartOfNewPage = $bStartOfPageBreak
$iError = ($oColumn.IsStartOfNewPage() = $bStartOfPageBreak) ? ($iError) : (BitOR($iError, 2))
EndIf
Return ($iError > 0) ? (SetError($__LO_STATUS_PROP_SETTING_ERROR, $iError, 0)) : (SetError($__LO_STATUS_SUCCESS, 0, 1))
EndFunc ;==>_LOCalc_RangeColumnPageBreak
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOCalc_RangeColumnsGetCount
; Description ...: Retrieve the total count of Columns contained in a Range.
; Syntax ........: _LOCalc_RangeColumnsGetCount(ByRef $oRange)
; Parameters ....: $oRange - [in/out] an object. A Cell Range or Cell object returned by a previous _LOCalc_RangeGetCellByName, _LOCalc_RangeGetCellByPosition, _LOCalc_RangeColumnGetObjByPosition, _LOCalc_RangeColumnGetObjByName, _LOcalc_RangeRowGetObjByPosition, _LOCalc_SheetGetObjByName, or _LOCalc_SheetGetActive function.
; Return values .: Success: Integer
; Failure: 0 and sets the @Error and @Extended flags to non-zero.
; --Input Errors--
; @Error 1 @Extended 1 Return 0 = $oRange not an Object.
; --Processing Errors--
; @Error 3 @Extended 1 Return 0 = Failed to retrieve Columns Object.
; --Success--
; @Error 0 @Extended 0 Return Integer = Success. Returning number of Columns contained in the Range.
; Author ........: donnyh13
; Modified ......:
; Remarks .......: There is a fixed number of Columns per sheet, but different L.O. versions contain different amounts of Columns. But this also helps to determine how many columns are contained in a Cell Range.
; Related .......:
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOCalc_RangeColumnsGetCount(ByRef $oRange)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOCalc_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $oColumns
If Not IsObj($oRange) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
$oColumns = $oRange.getColumns()
If Not IsObj($oColumns) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 1, 0)
Return SetError($__LO_STATUS_SUCCESS, 0, $oColumns.Count())
EndFunc ;==>_LOCalc_RangeColumnsGetCount
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOCalc_RangeColumnVisible
; Description ...: Set or Retrieve the Column's visibility setting.
; Syntax ........: _LOCalc_RangeColumnVisible(ByRef $oColumn[, $bVisible = Null])
; Parameters ....: $oColumn - an object. A Column object returned by a previous _LOCalc_RangeColumnGetObjByPosition, or _LOCalc_RangeColumnGetObjByName function.
; $bVisible - [optional] a boolean value. Default is Null. If True, the Column is Visible.
; Return values .: Success: 1 or Boolean
; Failure: 0 and sets the @Error and @Extended flags to non-zero.
; --Input Errors--
; @Error 1 @Extended 1 Return 0 = $oColumn not an Object.
; @Error 1 @Extended 2 Return 0 = $bVisible not a Boolean.
; --Property Setting Errors--
; @Error 4 @Extended ? Return 0 = Some settings were not successfully set. Use BitAND to test @Extended for following values:
; | 1 = Error setting $bVisible
; --Success--
; @Error 0 @Extended 0 Return 1 = Success. Settings were successfully set.
; @Error 0 @Extended 1 Return Boolean = Success. All optional parameters were set to Null, returning Column's current visibility setting.
; Author ........: donnyh13
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOCalc_RangeColumnVisible(ByRef $oColumn, $bVisible = Null)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOCalc_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $iError = 0
If Not IsObj($oColumn) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If ($bVisible = Null) Then Return SetError($__LO_STATUS_SUCCESS, 1, $oColumn.IsVisible())
If Not IsBool($bVisible) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
$oColumn.IsVisible = $bVisible
$iError = ($oColumn.IsVisible() = $bVisible) ? ($iError) : (BitOR($iError, 1))
Return ($iError > 0) ? (SetError($__LO_STATUS_PROP_SETTING_ERROR, $iError, 0)) : (SetError($__LO_STATUS_SUCCESS, 0, 1))
EndFunc ;==>_LOCalc_RangeColumnVisible
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOCalc_RangeColumnWidth
; Description ...: Set or Retrieve the Column's Width settings.
; Syntax ........: _LOCalc_RangeColumnWidth(ByRef $oColumn[, $bOptimal = Null[, $iWidth = Null]])
; Parameters ....: $oColumn - an object. A Column object returned by a previous _LOCalc_RangeColumnGetObjByPosition, or _LOCalc_RangeColumnGetObjByName function.
; $bOptimal - [optional] a boolean value. Default is Null. If True, the Optimal width is automatically chosen. See Remarks.
; $iWidth - [optional] an integer value (0-34464). Default is Null. The Width of the Column, set in Micrometers.
; Return values .: Success: 1 or Array
; Failure: 0 and sets the @Error and @Extended flags to non-zero.
; --Input Errors--
; @Error 1 @Extended 1 Return 0 = $oColumn not an Object.
; @Error 1 @Extended 2 Return 0 = $bOptimal not a Boolean.
; @Error 1 @Extended 3 Return 0 = $iWidth not an Integer, less than 0 or greater than 34464.
; --Property Setting Errors--
; @Error 4 @Extended ? Return 0 = Some settings were not successfully set. Use BitAND to test @Extended for following values:
; | 1 = Error setting $bOptimal
; | 2 = Error setting $iWidth
; --Success--
; @Error 0 @Extended 0 Return 1 = Success. Settings were successfully set.
; @Error 0 @Extended 1 Return Array = Success. All optional parameters were set to Null, returning current settings in a 2 Element Array with values in order of function parameters.
; Author ........: donnyh13
; Modified ......:
; Remarks .......: $bOptimal only accepts True. False will return an error. Calling True again returns the cell to optimal width, setting a custom width essentially disables it.
; I am presently unable to find a setting for Optimal Width "Add" Value.
; Related .......: _LOCalc_ConvertFromMicrometer, _LOCalc_ConvertToMicrometer
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOCalc_RangeColumnWidth(ByRef $oColumn, $bOptimal = Null, $iWidth = Null)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOCalc_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $avWidth[2]
Local $iError = 0
If Not IsObj($oColumn) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If __LOCalc_VarsAreNull($bOptimal, $iWidth) Then
__LOCalc_ArrayFill($avWidth, $oColumn.OptimalWidth(), $oColumn.Width())
Return SetError($__LO_STATUS_SUCCESS, 1, $avWidth)
EndIf
If ($bOptimal <> Null) Then
If Not IsBool($bOptimal) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
$oColumn.OptimalWidth = $bOptimal
$iError = ($oColumn.OptimalWidth() = $bOptimal) ? ($iError) : (BitOR($iError, 1))
EndIf
If ($iWidth <> Null) Then
If Not __LOCalc_IntIsBetween($iWidth, 0, 34464) Then Return SetError($__LO_STATUS_INPUT_ERROR, 3, 0)
$oColumn.Width = $iWidth
$iError = (__LOCalc_IntIsBetween($oColumn.Width(), $iWidth - 1, $iWidth + 1)) ? ($iError) : (BitOR($iError, 2))
EndIf
Return ($iError > 0) ? (SetError($__LO_STATUS_PROP_SETTING_ERROR, $iError, 0)) : (SetError($__LO_STATUS_SUCCESS, 0, 1))
EndFunc ;==>_LOCalc_RangeColumnWidth
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOCalc_RangeCompute
; Description ...: Perform a Computation function on a Range. See Remarks.
; Syntax ........: _LOCalc_RangeCompute(ByRef $oRange, $iFunction)
; Parameters ....: $oRange - [in/out] an object. A Cell Range or Cell object returned by a previous _LOCalc_RangeGetCellByName, _LOCalc_RangeGetCellByPosition, _LOCalc_RangeColumnGetObjByPosition, _LOCalc_RangeColumnGetObjByName, _LOcalc_RangeRowGetObjByPosition, _LOCalc_SheetGetObjByName, or _LOCalc_SheetGetActive function.
; $iFunction - an integer value (0-12). The Computation Function to perform. See Constants $LOC_COMPUTE_FUNC_* as defined in LibreOfficeCalc_Constants.au3.
; Return values .: Success: Number
; Failure: 0 and sets the @Error and @Extended flags to non-zero.
; --Input Errors--
; @Error 1 @Extended 1 Return 0 = $oRange not an Object.
; @Error 1 @Extended 2 Return 0 = $iFunction not an Integer, less than 0 or greater than 12. See Constants $LOC_COMPUTE_FUNC_* as defined in LibreOfficeCalc_Constants.au3.
; --Processing Errors--
; @Error 3 @Extended 1 Return 0 = Failed to perform computation.
; --Success--
; @Error 0 @Extended 0 Return Number = Success. Successfully performed the requested computation, returning the result as a Numerical value.
; Author ........: donnyh13
; Modified ......:
; Remarks .......: This makes no changes in the document itself, it only returns the result of the computation.
; Related .......:
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOCalc_RangeCompute(ByRef $oRange, $iFunction)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOCalc_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $nResult
If Not IsObj($oRange) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If Not __LOCalc_IntIsBetween($iFunction, $LOC_COMPUTE_FUNC_NONE, $LOC_COMPUTE_FUNC_VARP) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
$nResult = $oRange.computeFunction($iFunction)
If Not IsNumber($nResult) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 1, 0)
Return SetError($__LO_STATUS_SUCCESS, 0, $nResult)
EndFunc ;==>_LOCalc_RangeCompute
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOCalc_RangeCopyMove
; Description ...: Copy or Move a Cell or Cell Range to another range.
; Syntax ........: _LOCalc_RangeCopyMove(ByRef $oSheet, ByRef $oRangeSrc, ByRef $oRangeDest[, $bMove = False])
; Parameters ....: $oSheet - [in/out] an object. A Sheet object returned by a previous _LOCalc_SheetAdd, _LOCalc_SheetGetActive, _LOCalc_SheetCopy, or _LOCalc_SheetGetObjByName function.
; $oRangeSrc - [in/out] an object. The Cell or Cell Range to copy or move from. A Cell Range or Cell object returned by a previous _LOCalc_RangeGetCellByName, _LOCalc_RangeGetCellByPosition, _LOCalc_RangeColumnGetObjByPosition, _LOCalc_RangeColumnGetObjByName, _LOcalc_RangeRowGetObjByPosition, _LOCalc_SheetGetObjByName, or _LOCalc_SheetGetActive function.
; $oRangeDest - [in/out] an object. The Cell or Cell Range to copy or move to. A Cell Range or Cell object returned by a previous _LOCalc_RangeGetCellByName, _LOCalc_RangeGetCellByPosition, _LOCalc_RangeColumnGetObjByPosition, _LOCalc_RangeColumnGetObjByName, _LOcalc_RangeRowGetObjByPosition, _LOCalc_SheetGetObjByName, or _LOCalc_SheetGetActive function.
; $bMove - [optional] a boolean value. Default is False. If True, the cell range is moved to the destination. If False, the Cell Range is only copied.
; Return values .: Success: 1
; Failure: 0 and sets the @Error and @Extended flags to non-zero.
; --Input Errors--
; @Error 1 @Extended 1 Return 0 = $oSheet not an Object.
; @Error 1 @Extended 2 Return 0 = $oRangeSrc not an Object.
; @Error 1 @Extended 3 Return 0 = $oRangeDest not an Object.
; @Error 1 @Extended 4 Return 0 = $bMove not a Boolean.
; --Initialization Errors--
; @Error 2 @Extended 1 Return 0 = Failed to create "com.sun.star.table.CellAddress" Struct.
; --Processing Errors--
; @Error 3 @Extended 1 Return 0 = Failed to retrieve Source Cell Range Address.
; @Error 3 @Extended 2 Return 0 = Failed to retrieve Destination Cell Range Address.
; --Success--
; @Error 0 @Extended 0 Return 1 = Success. Cell or Cell range was successfully copied to destination.
; @Error 0 @Extended 1 Return 1 = Success. Cell or Cell range was successfully moved to destination.
; Author ........: donnyh13
; Modified ......:
; Remarks .......: The Destination Range can be on different Sheet from Source.
; $oSheet is the source sheet where $oRangeSrc is located.
; Related .......:
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOCalc_RangeCopyMove(ByRef $oSheet, ByRef $oRangeSrc, ByRef $oRangeDest, $bMove = False)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOCalc_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $tCellSrcAddr, $tInputCellDestAddr, $tCellDestAddr
If Not IsObj($oSheet) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If Not IsObj($oRangeSrc) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
If Not IsObj($oRangeDest) Then Return SetError($__LO_STATUS_INPUT_ERROR, 3, 0)
If Not IsBool($bMove) Then Return SetError($__LO_STATUS_INPUT_ERROR, 4, 0)
$tCellSrcAddr = $oRangeSrc.RangeAddress()
If Not IsObj($tCellSrcAddr) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 1, 0)
$tInputCellDestAddr = $oRangeDest.RangeAddress()
If Not IsObj($tInputCellDestAddr) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 2, 0)
$tCellDestAddr = __LOCalc_CreateStruct("com.sun.star.table.CellAddress")
If Not IsObj($tCellDestAddr) Then Return SetError($__LO_STATUS_INIT_ERROR, 1, 0)
$tCellDestAddr.Sheet = $tInputCellDestAddr.Sheet()
$tCellDestAddr.Column = $tInputCellDestAddr.StartColumn()
$tCellDestAddr.Row = $tInputCellDestAddr.StartRow()
If $bMove Then
$oSheet.MoveRange($tCellDestAddr, $tCellSrcAddr)
Return SetError($__LO_STATUS_SUCCESS, 1, 1)
Else
$oSheet.CopyRange($tCellDestAddr, $tCellSrcAddr)
Return SetError($__LO_STATUS_SUCCESS, 0, 1)
EndIf
EndFunc ;==>_LOCalc_RangeCopyMove
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOCalc_RangeCreateCursor
; Description ...: Create a Sheet Cursor for a particular range.
; Syntax ........: _LOCalc_RangeCreateCursor(ByRef $oSheet, ByRef $oRange)
; Parameters ....: $oSheet - [in/out] an object. A Sheet object returned by a previous _LOCalc_SheetAdd, _LOCalc_SheetGetActive, _LOCalc_SheetCopy, or _LOCalc_SheetGetObjByName function.
; $oRange - [in/out] an object. A Cell Range or Cell object returned by a previous _LOCalc_RangeGetCellByName, _LOCalc_RangeGetCellByPosition, _LOCalc_RangeColumnGetObjByPosition, _LOCalc_RangeColumnGetObjByName, _LOcalc_RangeRowGetObjByPosition, _LOCalc_SheetGetObjByName, or _LOCalc_SheetGetActive function.
; Return values .: Success: Object
; Failure: 0 and sets the @Error and @Extended flags to non-zero.
; --Input Errors--
; @Error 1 @Extended 1 Return 0 = $oSheet not an Object.
; @Error 1 @Extended 2 Return 0 = $oRange not an Object.
; --Initialization Errors--
; @Error 2 @Extended 1 Return 0 = Failed to create a Sheet Cursor.
; --Success--
; @Error 0 @Extended 0 Return Object = Success. Successfully created a Sheet Cursor for the specified Range, returning its Object.
; Author ........: donnyh13
; Modified ......:
; Remarks .......: A Sheet Cursor can be used in functions accepting a range. When created, the Cursor will have the called range selected.
; Related .......:
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOCalc_RangeCreateCursor(ByRef $oSheet, ByRef $oRange)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOCalc_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $oSheetCursor
If Not IsObj($oSheet) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If Not IsObj($oRange) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
$oSheetCursor = $oSheet.createCursorByRange($oRange)
If Not IsObj($oSheetCursor) Then Return SetError($__LO_STATUS_INIT_ERROR, 1, 0)
Return SetError($__LO_STATUS_SUCCESS, 0, $oSheetCursor)
EndFunc ;==>_LOCalc_RangeCreateCursor
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOCalc_RangeData
; Description ...: Set or Retrieve Data in a Range.
; Syntax ........: _LOCalc_RangeData(ByRef $oRange[, $aavData = Null[, $bStrictSize = False]])
; Parameters ....: $oRange - [in/out] an object. The Cell or Cell Range to set or retrieve data . A Cell Range or Cell object returned by a previous _LOCalc_RangeGetCellByName, _LOCalc_RangeGetCellByPosition, _LOCalc_RangeColumnGetObjByPosition, _LOCalc_RangeColumnGetObjByName, _LOcalc_RangeRowGetObjByPosition, _LOCalc_SheetGetObjByName, or _LOCalc_SheetGetActive function.
; $aavData - [optional] an array of Arrays containing variants. Default is Null. An Array of Arrays containing data, strings or numbers, to fill the range with. See remarks.
; $bStrictSize - [optional] a boolean value. Default is False. If True, The Range size must explicitly match the array sizing. If False, The Range will be resized right or down to fit the Array sizing.
; Return values .: Success: 1 or Array
; Failure: 0 or ? and sets the @Error and @Extended flags to non-zero.
; --Input Errors--
; @Error 1 @Extended 1 Return 0 = $oRange not an Object.
; @Error 1 @Extended 2 Return 0 = $aavData not an Array.
; @Error 1 @Extended 3 Return 0 = $bStrictSize not a Boolean.
; @Error 1 @Extended 4 Return 0 = $bStrictSize set to True, and $aavData array contains less or more elements than number of rows contained in the cell range.
; @Error 1 @Extended 5 Return ? = Element of $aavData does not contain an array. Returning array element number of $aavData containing error.
; @Error 1 @Extended 6 Return ? = $bStrictSize set to True, and Array contained in $aavData has less or more elements than number of columns in the cell range. Returning array element number of $aavData containing faulty array.
; @Error 1 @Extended 7 Return ? = $bStrictSize set to False, and Array contained in $aavData has less or more elements than first Array contained in $aavData. Returning array element number of $aavData containing faulty array.
; --Processing Errors--
; @Error 3 @Extended 1 Return 0 = Failed to retrieve array of Formula Data contained in the Cell Range.
; @Error 3 @Extended 2 Return 0 = Failed to retrieve Start of Row from Cell Range.
; @Error 3 @Extended 3 Return 0 = Failed to retrieve End of Row from Cell Range.
; @Error 3 @Extended 4 Return 0 = Expanding Range would exceed number of Rows contained in Sheet.
; @Error 3 @Extended 5 Return 0 = Failed to re-size Cell Range Rows.
; @Error 3 @Extended 6 Return 0 = Failed to retrieve Start of Column from Cell Range.
; @Error 3 @Extended 7 Return 0 = Failed to retrieve End of Column from Cell Range.
; @Error 3 @Extended 8 Return 0 = Expanding Range would exceed number of Columns contained in Sheet.
; @Error 3 @Extended 9 Return 0 = Failed to re-size Cell Range Columns.
; --Success--
; @Error 0 @Extended 0 Return 1 = Success. Data was successfully set for the cell range.
; @Error 0 @Extended 1 Return Array of Arrays = Success. $aavData set to Null, returning an array containing arrays, which contain any data content contained in the cell range.
; Author ........: donnyh13
; Modified ......:
; Remarks .......: This function will return Strings and Numbers contained in the cell range when $aavData is called with Null keyword. Array will be an array of arrays. The internal arrays will contain numerical or string data, depending on cell content.
; $aavData must be an array containing arrays. If $bStrictSize is set to True, the main Array's element count must match the row count contained in the Cell Range, and each internal Array's element count must match the column count of the Cell Range it is to fill. All internal arrays must be the same size.
; Any data previously contained in the Cell Range will be overwritten.
; All array elements must contain appropriate data, strings or numbers.
; Formulas will be inserted as strings only, and will not be valid.
; Related .......:
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOCalc_RangeData(ByRef $oRange, $aavData = Null, $bStrictSize = False)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOCalc_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $iStart, $iEnd
If Not IsObj($oRange) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If ($aavData = Null) Then
$aavData = $oRange.getDataArray()
If Not IsArray($aavData) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 1, 0)
Return SetError($__LO_STATUS_SUCCESS, 1, $aavData)
EndIf
If Not IsArray($aavData) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
If Not IsBool($bStrictSize) Then Return SetError($__LO_STATUS_INPUT_ERROR, 3, 0)
; Determine if the Array is sized appropriately
$iStart = $oRange.RangeAddress.StartRow()
If Not IsInt($iStart) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 2, 0)
$iEnd = $oRange.RangeAddress.EndRow()
If Not IsInt($iEnd) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 3, 0)
If $bStrictSize Then ; If Array is wrongly sized, return an error.
If (UBound($aavData) <> ($iEnd - $iStart + 1)) Then Return SetError($__LO_STATUS_INPUT_ERROR, 4, 0)
Else ; Expand the Range to fit the Array
If (UBound($aavData) <> ($iEnd - $iStart + 1)) Then
If (($oRange.RangeAddress.StartRow() + UBound($aavData)) > $oRange.Spreadsheet.getRows.getCount()) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 4, 0) ; Check if resizing range is possible.
$oRange = $oRange.Spreadsheet.getCellRangeByPosition($oRange.RangeAddress.StartColumn(), $oRange.RangeAddress.StartRow(), $oRange.RangeAddress.EndColumn(), ($oRange.RangeAddress.StartRow() + UBound($aavData) - 1))
If Not IsObj($oRange) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 5, 0)
EndIf
EndIf
$iStart = $oRange.RangeAddress.StartColumn()
If Not IsInt($iStart) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 6, 0)
$iEnd = $oRange.RangeAddress.EndColumn()
If Not IsInt($iEnd) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 7, 0)
If $bStrictSize Then ; Check if the internal arrays are sized correctly, return error if not.
For $i = 0 To UBound($aavData) - 1
If Not IsArray($aavData[$i]) Then Return SetError($__LO_STATUS_INPUT_ERROR, 5, $i)
If (UBound($aavData[$i]) <> ($iEnd - $iStart + 1)) Then Return SetError($__LO_STATUS_INPUT_ERROR, 6, $i)
Next
Else ; Check if the internal arrays are sized correctly, resize range if not.
For $i = 0 To UBound($aavData) - 1
If Not IsArray($aavData[$i]) Then Return SetError($__LO_STATUS_INPUT_ERROR, 5, $i)
If (UBound($aavData[$i]) <> UBound($aavData[0])) Then Return SetError($__LO_STATUS_INPUT_ERROR, 7, $i) ; If all arrays aren't same size as first array, then error.
Next
If (UBound($aavData[0]) <> ($iEnd - $iStart + 1)) Then ; Resize the Range.
If (($oRange.RangeAddress.StartColumn() + UBound($aavData[0])) > $oRange.Spreadsheet.getColumns.getCount()) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 8, 0)
$oRange = $oRange.Spreadsheet.getCellRangeByPosition($oRange.RangeAddress.StartColumn(), $oRange.RangeAddress.StartRow(), ($oRange.RangeAddress.StartColumn() + UBound($aavData[0]) - 1), $oRange.RangeAddress.EndRow())
If Not IsObj($oRange) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 9, 0)
EndIf
EndIf
$oRange.setDataArray($aavData)
Return SetError($__LO_STATUS_SUCCESS, 0, 1)
EndFunc ;==>_LOCalc_RangeData
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOCalc_RangeDatabaseAdd
; Description ...: Add a Database Range to a document.
; Syntax ........: _LOCalc_RangeDatabaseAdd(ByRef $oDoc, $oRange, $sName[, $bColumnHeaders = True[, $bTotalsRow = False[, $bAddDeleteCells = True[, $bKeepFormatting = True[, $bDontSaveImport = False[, $bAutoFilter = False]]]]]])
; Parameters ....: $oDoc - [in/out] an object. A Document object returned by a previous _LOCalc_DocOpen, _LOCalc_DocConnect, or _LOCalc_DocCreate function.
; $oRange - an object. The Range to designate as a Database range. A Cell Range or Cell object returned by a previous _LOCalc_RangeGetCellByName, _LOCalc_RangeGetCellByPosition, _LOCalc_RangeColumnGetObjByPosition, _LOCalc_RangeColumnGetObjByName, _LOcalc_RangeRowGetObjByPosition, _LOCalc_SheetGetObjByName, or _LOCalc_SheetGetActive function.
; $sName - a string value. The unique name of the Database Range to create.
; $bColumnHeaders - [optional] a boolean value. Default is True. If True, the top row is considered a Header/label.
; $bTotalsRow - [optional] a boolean value. Default is False. If True, the bottom row will be considered a totals row.
; $bAddDeleteCells - [optional] a boolean value. Default is True. If True, columns or rows are inserted or deleted when the size of the range is changed by an update operation.
; $bKeepFormatting - [optional] a boolean value. Default is True. If True, cell formats are extended when the size of the range is changed by an update operation.
; $bDontSaveImport - [optional] a boolean value. Default is False. If True, cell contents within the database range are left out when the document is saved.
; $bAutoFilter - [optional] a boolean value. Default is False. If True, the Auto Filter option is enabled.
; Return values .: Success: Object
; Failure: 0 and sets the @Error and @Extended flags to non-zero.
; --Input Errors--
; @Error 1 @Extended 1 Return 0 = $oDoc not an Object.
; @Error 1 @Extended 2 Return 0 = $oRange not an Object.
; @Error 1 @Extended 3 Return 0 = $sName not a String.
; @Error 1 @Extended 4 Return 0 = $bColumnHeaders not a Boolean.
; @Error 1 @Extended 5 Return 0 = $bTotalsRow not a Boolean.
; @Error 1 @Extended 6 Return 0 = $bAddDeleteCells not a Boolean.
; @Error 1 @Extended 7 Return 0 = $bKeepFormatting not a Boolean.
; @Error 1 @Extended 8 Return 0 = $bDontSaveImport not a Boolean.
; @Error 1 @Extended 9 Return 0 = $bAutoFilter not a Boolean.
; @Error 1 @Extended 10 Return 0 = Document called in $oDoc already contains a Database Range named the same as called in $sName.
; --Processing Errors--
; @Error 3 @Extended 1 Return 0 = Failed to retrieve Database Ranges Object.
; @Error 3 @Extended 2 Return 0 = Failed to retrieve new Database Range's Object.
; --Success--
; @Error 0 @Extended 0 Return Object = Success. Successfully added a new Database Range, returning its Object.
; Author ........: donnyh13
; Modified ......:
; Remarks .......:
; Related .......: _LOCalc_RangeDatabaseExists, _LOCalc_RangeDatabaseDelete
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOCalc_RangeDatabaseAdd(ByRef $oDoc, $oRange, $sName, $bColumnHeaders = True, $bTotalsRow = False, $bAddDeleteCells = True, $bKeepFormatting = True, $bDontSaveImport = False, $bAutoFilter = False)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOCalc_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $oDatabaseRanges, $oDatabaseRange
If Not IsObj($oDoc) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If Not IsObj($oRange) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
If Not IsString($sName) Then Return SetError($__LO_STATUS_INPUT_ERROR, 3, 0)
If Not IsBool($bColumnHeaders) Then Return SetError($__LO_STATUS_INPUT_ERROR, 4, 0)
If Not IsBool($bTotalsRow) Then Return SetError($__LO_STATUS_INPUT_ERROR, 5, 0)
If Not IsBool($bAddDeleteCells) Then Return SetError($__LO_STATUS_INPUT_ERROR, 6, 0)
If Not IsBool($bKeepFormatting) Then Return SetError($__LO_STATUS_INPUT_ERROR, 7, 0)
If Not IsBool($bDontSaveImport) Then Return SetError($__LO_STATUS_INPUT_ERROR, 8, 0)
If Not IsBool($bAutoFilter) Then Return SetError($__LO_STATUS_INPUT_ERROR, 9, 0)
$oDatabaseRanges = $oDoc.DatabaseRanges()
If Not IsObj($oDatabaseRanges) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 1, 0)
If $oDatabaseRanges.hasByName($sName) Then Return SetError($__LO_STATUS_INPUT_ERROR, 10, 0)
$oDatabaseRanges.addNewByName($sName, $oRange.RangeAddress())
$oDatabaseRange = $oDatabaseRanges.getByName($sName)
If Not IsObj($oDatabaseRange) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 2, 0)
With $oDatabaseRange
.ContainsHeader = $bColumnHeaders
.TotalsRow = $bTotalsRow
.MoveCells = $bAddDeleteCells
.KeepFormats = $bKeepFormatting
.StripData = $bDontSaveImport
.AutoFilter = $bAutoFilter
EndWith
Return SetError($__LO_STATUS_SUCCESS, 0, $oDatabaseRange)
EndFunc ;==>_LOCalc_RangeDatabaseAdd
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOCalc_RangeDatabaseDelete
; Description ...: Delete a Database Range from the document.
; Syntax ........: _LOCalc_RangeDatabaseDelete(ByRef $oDoc, $oDatabaseRange)
; Parameters ....: $oDoc - [in/out] an object. A Document object returned by a previous _LOCalc_DocOpen, _LOCalc_DocConnect, or _LOCalc_DocCreate function.
; $oDatabaseRange - an object. A Database Range Object as returned from _LOCalc_RangeDatabaseAdd or _LOCalc_RangeDatabaseGetObjByName.
; Return values .: Success: 1
; Failure: 0 and sets the @Error and @Extended flags to non-zero.
; --Input Errors--
; @Error 1 @Extended 1 Return 0 = $oDoc not an Object.
; @Error 1 @Extended 2 Return 0 = $oDatabaseRange not an Object and not a String.
; --Processing Errors--
; @Error 3 @Extended 1 Return 0 = Failed to retrieve Database Ranges Object.
; @Error 3 @Extended 2 Return 0 = Failed to retrieve Database Range name.
; @Error 3 @Extended 3 Return 0 = Failed to delete requested Database Range.
; --Success--
; @Error 0 @Extended 0 Return 1 = Success. Successfully deleted the requested Database Range.
; Author ........: donnyh13
; Modified ......:
; Remarks .......:
; Related .......: _LOCalc_RangeDatabaseAdd
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOCalc_RangeDatabaseDelete(ByRef $oDoc, $oDatabaseRange)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOCalc_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $oDatabaseRanges
Local $sDatabaseRange
If Not IsObj($oDoc) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If Not IsObj($oDatabaseRange) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
$oDatabaseRanges = $oDoc.DatabaseRanges()
If Not IsObj($oDatabaseRanges) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 1, 0)
$sDatabaseRange = $oDatabaseRange.Name()
If Not IsString($sDatabaseRange) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 2, 0)
$oDatabaseRanges.removeByName($sDatabaseRange)
If $oDatabaseRanges.hasByName($sDatabaseRange) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 3, 0)
Return SetError($__LO_STATUS_SUCCESS, 0, 1)
EndFunc ;==>_LOCalc_RangeDatabaseDelete
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOCalc_RangeDatabaseExists
; Description ...: Check if a Database Range exists in a document.
; Syntax ........: _LOCalc_RangeDatabaseExists(ByRef $oDoc, $sName)
; Parameters ....: $oDoc - [in/out] an object.
; $sName - a string value.
; Return values .: Success: Boolean
; Failure: 0 and sets the @Error and @Extended flags to non-zero.
; --Input Errors--
; @Error 1 @Extended 1 Return 0 = $oDoc not an Object.
; @Error 1 @Extended 2 Return 0 = $sName not a String.
; --Processing Errors--
; @Error 3 @Extended 1 Return 0 = Failed to retrieve Database Ranges Object.
; @Error 3 @Extended 2 Return 0 = Failed to query whether document contains the called name.
; --Success--
; @Error 0 @Extended 0 Return Boolean = Success. Returns True if the document contains a Database Range by the called name. Else False.
; Author ........: donnyh13
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOCalc_RangeDatabaseExists(ByRef $oDoc, $sName)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOCalc_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $oDatabaseRanges
Local $bExists
If Not IsObj($oDoc) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If Not IsString($sName) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
$oDatabaseRanges = $oDoc.DatabaseRanges()
If Not IsObj($oDatabaseRanges) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 1, 0)