Mi problema es que tengo un programa que lee los datos desde una hoja de Excel .xlsb, pero cuando el archivo de Excel está abierto, entonces me pide que le guarde. Por qué?
async Task<bool> ReadVariable()
{
bool succeeded = false;
while (!succeeded)
{
//open file excel using microsoft dll
Excel.Application app = new Excel.Application();
//open workbook
Workbook wk = app.Workbooks.Open(excelpath, ReadOnly : true);
//get first sheet
Worksheet sh = wk.Worksheets[1];
//get cell
// Cells[unten/rechts] Example: [1,2] = B1
var day1tag = sh.Cells[27, 2].Value.ToString();
exceltest1.Text = day1tag;
var day1früh = sh.Cells[26, 2].Value.ToString();
Day24oee24.Text = day1früh;
app.DisplayAlerts = false;
wk.Close(SaveChanges : false);
app.Quit();
await Task.Delay(15000);
//await Task.Delay(108000000);
}
return succeeded;
}