Copy Range including Formats and Forumulas
We found the cause for this...a call to set the range style in another
function was messing up the copy.
"ALV" wrote:
We are trying to copy a Range to another worksheet in a C# Excel 2007 add-in
and want to get everything from the source range, including the cell formats
and formulas.
Our code is:
Excel.ListObject inTable -- is passed to the function
Excel.Range drange = inWorksheet.get_Range("A1", Type.Missing);
Excel.Range tableRange = drange;
Excel.ListColumn lcolumn = inTable.ListColumns[column];
lcolumn.Range.Copy(drange);
Excel.Range trange = drange.get_Resize(lcolumn.Range.Count, 1);
tableRange = inTable.Application.Union(tableRange, trange, Type.Missing,
Type.Missing,Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing,
The result of the copy has only the values from the source range.
Thanks.
|