When I try to Save a Workbook after combining 2 different files the component throws a “Object reference not set to an instance of an object” with the following stack trace:
at xabb58b8f2887ff8e.x50d9ace66d7842b0.x6e768110e4d8667f(FormatCondition x4d16ee7ee4ba1146, String xcde081a7199c823a)
at xabb58b8f2887ff8e.x50d9ace66d7842b0.xbf8e11070c9420e9(XmlTextWriter xbdfb620b7167944b, FormatCondition x4d16ee7ee4ba1146, String xcde081a7199c823a, Int32 x32e9b596b865a6b6)
at xabb58b8f2887ff8e.x50d9ace66d7842b0.x869d8fa22bbd2c1b(XmlTextWriter xbdfb620b7167944b)
at xabb58b8f2887ff8e.x50d9ace66d7842b0.x6210059f049f0d48(XmlTextWriter xbdfb620b7167944b)
at xabb58b8f2887ff8e.xb440dd60010e3cc4.x7ef0a1369079a9c7(x6fc54f8ba8aae1d4 xd9171314ec0b2957)
at xabb58b8f2887ff8e.xb440dd60010e3cc4.xc228659948392f83(x6fc54f8ba8aae1d4 xd9171314ec0b2957)
at xabb58b8f2887ff8e.xb440dd60010e3cc4.x6b3641eeb6a37b82()
at xabb58b8f2887ff8e.xb440dd60010e3cc4.x6210059f049f0d48()
at Aspose.Cells.Workbook.Save(Stream stream, FileFormatType fileFormatType)
at Aspose.Cells.Workbook.Save(String fileName, FileFormatType fileFormatType)
Files are also attached, the original csv file along with the two xlsx files to combine.
This is the code:
string origLoc = (string)mngr.Parameters["original"];
FileFormatType saveType = FileFormatType.Excel2007Xlsx;
ArrayList files = (ArrayList)mngr.Parameters["files"];
string outputLoc = (string)mngr.Parameters["output"];
try
{
Workbook orig = new Workbook();
if ((origLoc.EndsWith(".csv")) || (origLoc.EndsWith(".CSV")))
orig.Open(origLoc, FileFormatType.CSV);
else if ((origLoc.EndsWith(".xlsx")) || (origLoc.EndsWith(".XLSX")))
orig.Open(origLoc, FileFormatType.Excel2007Xlsx);
else if ((origLoc.EndsWith(".xls")) || (origLoc.EndsWith(".XLS")))
orig.Open(origLoc, FileFormatType.Excel2003);
//combine files into orignal
for (int i = 0; i < files.Count; i++)
{
string filepath = (string)files[i];
Workbook current = new Workbook();
if ((filepath.EndsWith(".csv")) || (filepath.EndsWith(".CSV")))
current.Open(filepath, FileFormatType.CSV);
else if ((filepath.EndsWith(".xlsx")) || (filepath.EndsWith(".XLSX")))
current.Open(filepath, FileFormatType.Excel2007Xlsx);
else if ((filepath.EndsWith(".xls")) || (filepath.EndsWith(".XLS")))
current.Open(filepath, FileFormatType.Excel2003);
orig.Combine(current);
}
if (File.Exists(outputLoc))
File.Delete(outputLoc);
orig.Save(outputLoc, saveType);//Exception thrown here<a class="attachment" <a class="attachment" href="/uploads/default/23877">Files.zip</a> (16.7 KB)