Please provide us further details regarding your issue. Which version of Aspose.Cells for .NET you were using before. Also, please share your sample code to reproduce the issue and we will check it soon.
Well, I think your code is a mixture of Aspose.Cells APIs & Office Automation. You may simply use Aspose.Cells APIs to get your desired results. Please see the following code for your reference:
Aspose.Cells.Workbook asposeWS = new Aspose.Cells.Workbook();
Aspose.Cells.Cells cells = asposeWS.Worksheets[0].Cells;
//Create command object and Fill Reader
OleDbCommand oleDbSelectCommand1 = new OleDbCommand();
string path = "C:\\Program Files\\Microsoft Office\\OFFICE11\\SAMPLES\\Northwind.mdb";
string ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path;
OleDbConnection oleDbConnection1 = new OleDbConnection(ConnectionString);
oleDbSelectCommand1.CommandText = "SELECT CategoryID, CategoryName, Description FROM Categories";
oleDbSelectCommand1.Connection = oleDbConnection1;
oleDbConnection1.Open();
OleDbDataReader reader = oleDbSelectCommand1.ExecuteReader();
//Import data with header using Aspose.Cells
cells.ImportFromDataReader(reader, true,0, 0, true);
reader.Close();
oleDbConnection1.Close();
//Create Aspose.Cells Range and Apply Header Style
Range range = cells.CreateRange(0, 0, 1, cells.MaxDataColumn+1);
Style headerStyle = asposeWS.Styles[asposeWS.Styles.Add()];
headerStyle.ForegroundColor = Color.Black;
headerStyle.Pattern = BackgroundType.Solid;
headerStyle.Font.Color = Color.White;
StyleFlag headerStyleToken = new StyleFlag();
headerStyleToken.CellShading = true;
headerStyleToken.FontColor = true;
range.ApplyStyle(headerStyle, headerStyleToken);
asposeWS.Worksheets[0].AutoFitColumns();
asposeWS.Save("c:\\Reader.xls");
The Resultant File is attached.
Also, you may check the following documentation link for details regarding importing data to worksheet and see our online demos for your reference.
Aspose.Cells for .NET examples, plugins and showcases - GitHub - aspose-cells/Aspose.Cells-for-.NET: Aspose.Cells for .NET examples, plugins and showcases
If you still face any problem after updating your code, please create a simple console application to reproduce the issue and post it here and we will check it soon.
Well, we don't use any VSTO APIs at all. Some interfaces that you saw in my sample code are our internal ones. And they don't have anything to do with VSTO APIs.
Besides, I have another question:
I get unreadable contents error when I export the data in Excel 2007 format. But this happens only in some cases. So code is same but depending on resultset from database, I get this error. So I was wondering if you can provide any data related constraints/restrictions which might cause this issue.
I noticed that there are couple of fixes for this issue in latest release.
But I encountered original issue and could not use latest version. Original issue still happens at my end.
How can I assist in providing more info? Any comments?