I have been making application that read data from serial port then write it to excel(continuous).
There is no problem if i open current excel file after that the serial data is written, or the serial data was written then i open the current file.
The problem is after data of serial received, then program is writing data to excel and at the same time i try to open the current file or open another excel application from out of program (manually).
> error message: error: Bad extension for file(Exception from
> HRESULT:0x800401E6(MK_E_INVALIDEXTENSION) Line: mscorlib
Serial data received >> Open excel file >> Write data to excel >> Save as >>> Serial data received >> Open excel file >> Write data to excel >> Save as >>>
After data is written to excel, i didn't closed the workbook, i just make it invisible.
This is my sample code
Excel.Application oXL;
Excel._Workbook oWB;
Excel._Worksheet oSheet;
.....
oXL = new Excel.Application();
oWB = oXL.Workbooks.Open("C:\\Folder\\SerialData" + filenumber + ".xlsx", 0, false, 5, "", "", false, Excel.XlPlatform.xlWindows, "", true, false, 0, true, false, false);
oSheet = (Excel._Worksheet)oWB.Worksheets["Sheet" + sheetnumber];
.....
oWB.SaveAs("C:\\Folder\\SerialData" + filenumber + ".xlsx",Excel.XlFileFormat.xlWorkbookDefault, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Excel.XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
What is the solution? Can you provide me some sample code?
Thank you