Hi Aspose team,
if you execute attached project in test file you can find 5 data connections but Aspose.Cells has problem to read 2 of them causing that foreach is failing.
Can you please check?
Thx,
Oliver
DataConnectionsCast.zip (229.8 KB)
Hi Aspose team,
if you execute attached project in test file you can find 5 data connections but Aspose.Cells has problem to read 2 of them causing that foreach is failing.
Can you please check?
Thx,
Oliver
DataConnectionsCast.zip (229.8 KB)
I checked your file and found out of those 5 external connections only three are DBConnections, so you have to write/update your code accordingly.
e.g.
Sample code:
.......
// Check all the connections inside the workbook
for (int i = 0; i < workbook.DataConnections.Count; i++)
{
Aspose.Cells.ExternalConnections.ExternalConnection externalConnection = workbook.DataConnections[i];
DBConnection dbConn = externalConnection as DBConnection;
if (dbConn != null)
{
Console.WriteLine("Connection Name: " + dbConn.Name);
Console.WriteLine("Connection Info: " + dbConn.ConnectionInfo);
Console.WriteLine("Command type: " + dbConn.CommandType);
Console.WriteLine("Command: " + dbConn.Command);
Console.WriteLine("########################");
}
else {
Console.WriteLine("Connection Name: " + workbook.DataConnections[i].Name);
Console.WriteLine("Source File: " + workbook.DataConnections[i].SourceFile);
Console.WriteLine("########################");
}
}
Let us know if you still have any issue or confusion.