Hi, thank you.
I try new code:
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using Aspose.Cells;
namespace ConsoleApplication2
{
class Program
{
static void CreateTestWorkbook(string fileName, string imagePath, int imageCount)
{
Workbook workbook = new Workbook();
for (int i = 0; i < imageCount; i++)
workbook.Worksheets[0].Pictures.Add(0, 0, imagePath);
for (int i = 0; i < imageCount; i++)
workbook.Worksheets[0].Shapes.DeleteShape(workbook.Worksheets[0].Pictures[0]);
Workbook cworkbook = new Workbook();
cworkbook.Worksheets.Clear();
cworkbook.Combine(workbook);
cworkbook.Save("C" + fileName);
workbook.Save(fileName, FileFormatType.Excel2003);
}
static void Main(string[] args)
{
string firstWorkbook = "workbook1.xls";
string secondWorkbook = "workbook2.xls";
string imagePath = @"P:\alexr\BMS.BMP";
CreateTestWorkbook(firstWorkbook, imagePath, 20);
CreateTestWorkbook(secondWorkbook, imagePath, 0);
Console.WriteLine("{1} size = {0}", File.ReadAllBytes(firstWorkbook).Length, firstWorkbook);
Console.WriteLine("{1} size = {0}", File.ReadAllBytes(secondWorkbook).Length, secondWorkbook);
Console.WriteLine("C{1} size = {0}", File.ReadAllBytes("C"+firstWorkbook).Length, firstWorkbook);
Console.WriteLine("C{1} size = {0}", File.ReadAllBytes("C"+secondWorkbook).Length, secondWorkbook);
Console.ReadKey();
}
}
}
You can see that combined workbook have equal size. But i try use it in real code and get error:
Object reference not set to an instance of an object.
Stack Trace:
at Aspose.Cells.Name.ౝ(Worksheet , Worksheet )
at Aspose.Cells.Worksheet.ন(Worksheet , Boolean )
at Aspose.Cells.Worksheet.Copy(Worksheet sourceSheet)
at Aspose.Cells.Worksheets.ૡ(Worksheets ૢ)
at Aspose.Cells.Workbook.Combine(Workbook secondWorkbook)