Free Support Forum - aspose.com

Copy dropdown lists?

hi,

i have tryed to copy a range of cells.
works fine but the dropdown lists i have added in my excel template were not copied.

here is my copy code:



Excel xls = new Excel();
xls.Open(Server.MapPath(".") + “\template\Template_7.0.xls”, FileFormatType.Excel2003);

// first
xls.Worksheets[1].Cells.InsertRows(24, 6);
Range rngSrc = xls.Worksheets[1].Cells.CreateRange(“A18”, “AK23”);
Range rngDst = xls.Worksheets[1].Cells.CreateRange(“A24”, “AK29”);
rngDst.Copy(rngSrc);

// second
xls.Worksheets[1].Cells.InsertRows(9, 2);
Range rngSrc2 = xls.Worksheets[1].Cells.CreateRange(“A8”, “BV9”);
Range rngDst2 = xls.Worksheets[1].Cells.CreateRange(“A10”, “BV11”);
rngDst2.Copy(rngSrc2);

xls.Save(Server.MapPath(".") + “\output\report.xls”, SaveType.Default, FileFormatType.Excel2003, Response);

All style formats like bold text, font types etc etc were copied correctly.
Just the dropdown lists are missing.

thanks for help

i have solved it Big Smile

here is my solution:




Excel xls = new Excel();
xls.Open(Server.MapPath(".") + “\template\Template_7.0.xls”, FileFormatType.Excel2003);

// copy
xls.Worksheets[1].Cells.InsertRows(24, 6);
Range rngSrc = xls.Worksheets[1].Cells.CreateRange(“A18”, “AK23”);
Range rngDst = xls.Worksheets[1].Cells.CreateRange(“A24”, “AK29”);
rngDst.Copy(rngSrc);
xls.Worksheets[1].Cells.InsertRows(9, 2);
Range rngSrc2 = xls.Worksheets[1].Cells.CreateRange(“A8”, “BV9”);
Range rngDst2 = xls.Worksheets[1].Cells.CreateRange(“A10”, “BV11”);
rngDst2.Copy(rngSrc2);



// recreate validation
Validation vali = xls.Worksheets[1].Validations[xls.Worksheets[1].Validations.Add()];
vali.Type = ValidationType.List;
vali.Formula1 = “Selection1; Selection2; Selection3”;
CellArea rngArea;
rngArea.StartRow = 9;
rngArea.EndRow = 10;
rngArea.StartColumn = 50;
rngArea.EndColumn = 50;
 xls.Save(Server.MapPath(".") + “\output\report.xls”, SaveType.Default, FileFormatType.Excel2003, Response);