Help- problem Range.Copy

Excel ex = new Excel();
ex.Open( "SSTMPL2b.XLS" ); // included two sheets.

Cells cells1 = ex.Worksheets[1].Cells;
Cells cells0 = ex.Worksheets[0].Cells;

Range rngSrc = cells1.CreateRange( 14, 0, 10, 22 ); // included easy macro.
Range rngDst = cells0.CreateRange( 13, 0, 10, 22 ); // copy to another sheet.
rngDst.Copy( rngSrc );

ex.Save("test.xls", FileFormatType.Default );


but "test.xls" file is broken and "#REF!" cells appear.

That a bug while copying range in two difference worksheets. I will check and fix this issue ASAP.

Try this fix please.

Thank you for your quick reply and I tested a new object.
But, I found a other bug.

//-------------------------------------------------------
Excel ex = new Excel();
ex.Open( "SSTMPL2b.XLS" );

Cells cellSrc = ex.Worksheets[1].Cells;
Range rngSrc1 = cellSrc.CreateRange( 14,0,10,22 );

Cells cellDst = ex.Worksheets[0].Cells;

Range rngDst = cellDst.CreateRange( 30,0,10,22 );
rngDst.Copy( rngSrc1 );

ex.Worksheets[0].Copy( ex.Worksheets[1] ); // Copy to "Sheet2"

ex.Save("test.xls", FileFormatType.Default );
//-------------------------------------------------------

I opned the test.xls in Excel and input values that "D15"=1000 and "D31"=1000 in "Sheet2".

"D19"=1000 is valid and "D20"=2000 is valid.

But, Range.Copy Cells value is wrong.

"D35"=100 is invalid and "D36"=200 is invalid

Please try this fix.

I tested a new object.
I found a little bug again.

// ------------------------------------------------------
Excel ex = new Excel();
ex.Open( "SSTMPL2c.XLS" ); // new version

Cells cellSrc = ex.Worksheets[1].Cells;
Range rngSrc1 = cellSrc.CreateRange( 14,0,10,22 );

Cells cellDst = ex.Worksheets[0].Cells;

Range rngDst = cellDst.CreateRange( 30,0,10,22 );
rngDst.Copy( rngSrc1 );

ex.Worksheets[0].Copy( ex.Worksheets[1] );

ex.Save("test.xls", FileFormatType.Default );

// -------------------------------------------------------

Hatching cells( "A15" to "E24" ) of test.xls is different from that of SSTMPL2c.XLS.

Thank you for the report. Please try this attached fix.

Thank you for a fast reply.
My all tests passed it.
I think that my customer evaluates Aspose.Excel highly.

@y_furuya,
Please note that Aspose.Excel is discontinued now and no more active development is done for it in Aspose. Another advanced product Aspose.Cells has replaced it which supports all the features in Aspose.Excel as well as contains different latest features available in MS Excel. We can work with ranges using this new product in different ways. For example we can copy range data with style as demonstrated in the following sample code:

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);


// Instantiate a new Workbook.
Workbook workbook = new Workbook();

// Get the first Worksheet Cells.
Cells cells = workbook.Worksheets[0].Cells;

// Fill some sample data into the cells.
for (int i = 0; i < 50; i++)
{
    for (int j = 0; j < 10; j++)
    {
        cells[i, j].PutValue(i.ToString() + "," + j.ToString());
    }
}

// Create a range (A1:D3).
Range range = cells.CreateRange("A1", "D3");

// Create a style object.
Style style;
style = workbook.CreateStyle();
// Specify the font attribute.
style.Font.Name = "Calibri";
// Specify the shading color.
style.ForegroundColor = Color.Yellow;
style.Pattern = BackgroundType.Solid;
// Specify the border attributes.
style.Borders[BorderType.TopBorder].LineStyle = CellBorderType.Thin;
style.Borders[BorderType.TopBorder].Color = Color.Blue;
style.Borders[BorderType.BottomBorder].LineStyle = CellBorderType.Thin;
style.Borders[BorderType.BottomBorder].Color = Color.Blue;
style.Borders[BorderType.LeftBorder].LineStyle = CellBorderType.Thin;
style.Borders[BorderType.LeftBorder].Color = Color.Blue;
style.Borders[BorderType.RightBorder].LineStyle = CellBorderType.Thin;
style.Borders[BorderType.RightBorder].Color = Color.Blue;
// Create the styleflag object.
StyleFlag flag1 = new StyleFlag();
// Implement font attribute
flag1.FontName = true;
// Implement the shading / fill color.
flag1.CellShading = true;
// Implment border attributes.
flag1.Borders = true;
// Set the Range style.
range.ApplyStyle(style, flag1);

// Create a second range (C10:F12).
Range range2 = cells.CreateRange("C10", "F12");

// Copy the range data with formatting.
range2.Copy(range);

dataDir = dataDir + "CopyRange.out.xlsx";
// Save the excel file.
workbook.Save(dataDir);

Refer to the following articles for more information on ranges:
Create Access and Copy Named Ranges
Format and Modify Named Ranges
Setting Formula for Named Range
Copy Range Style Only

Give a try to this new product by downloading it from the following link:
Aspose.Cells for .NET (Latest Version)

Here is a runnable solution which contains hundreds of examples to demonstrate different features of Aspose.Cells.