Manipulate ExcelRange

Add-in Express™ Support Service
That's what is more important than anything else

Manipulate ExcelRange
How to save, store... 
Micha? G??bowski


Guest


Dear Sirs,

Is there any way to save ExcelRange for later use?
I mean sth. ExcelRange.SaveToFile.
To be able to restore values and formatting later with ExcelRange.LoadFromFile.

Michal
Posted 27 Jul, 2015 08:44:10 Top
Andrei Smolin


Add-in Express team


Posts: 18829
Joined: 2006-05-11
Hello Micha?,

You can use Range.Value to get (and set) an array of cell values. Please find some details at https://www.add-in-express.com/creating-addins-blog/2011/09/29/excel-read-update-cells/.


Andrei Smolin
Add-in Express Team Leader
Posted 27 Jul, 2015 09:12:42 Top
Micha? G??bowski


Guest


Dear Andrei,

Your link directs to samples in C# and VB.NET. In code there is assignment to string array. I use delphi and code:


ClipArr: array of array of String;
(...)
ARange := AWindow.RangeSelection;
ClipArr := ARange.Value;

does not work.

And one more question: does your code copies also cells formatting or only values (text/formulas)?

Michal
Posted 27 Jul, 2015 15:46:17 Top
Andrei Smolin


Add-in Express team


Posts: 18829
Joined: 2006-05-11
Hello Micha?,

The Range.Value property is described at https://msdn.microsoft.com/en-us/library/office/ff195193%28v=office.15%29.aspx. I've found a Delphi example at http://www.delphigroups.info/2/9/1015688.html.

This property returns an array of cell values; formatting isn't included. To retrieve formatting, you'll need to scan every cell and use the properties providing the required information.


Andrei Smolin
Add-in Express Team Leader
Posted 28 Jul, 2015 05:20:32 Top
Micha? G??bowski


Guest


Thank you Andrei for your hint. I coped with problem copying range to system clipboard and then using either HTML or rtf format to store formatting. Works perfectly.
Posted 09 Aug, 2015 05:32:39 Top
Andrei Smolin


Add-in Express team


Posts: 18829
Joined: 2006-05-11
Thank you for letting me know.


Andrei Smolin
Add-in Express Team Leader
Posted 10 Aug, 2015 02:12:04 Top