I use the Open from the Assets on xamarin then and i Open on the Workbooks when i build my app it stoped working but if i coding on normal Console it's working, What i forget ?
var asset = Application.Context.Assets.Open("test.xlsx");
new ExcelEngine().Excel.Workbooks.Open(asset);
https://help.syncfusion.com/file-formats/xlsio/create-read-edit-excel-files-in-xamarin-c-sharp
In Android, you could try the code below.
string filePath="test.xlsx";
using (ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2016;
var asset = Android.App.Application.Context.Assets.Open(filePath);
using (StreamReader sr = new StreamReader(asset))
{
var inputStream = sr.BaseStream;
//Open the Tab delimited CSV file
IWorkbook workbook = application.Workbooks.Open(inputStream, "\t");
IWorksheet sheet = workbook.Worksheets[0];
var s = sheet.Columns.Count();
}
}
The code works well on my side to get the Column count of the Excel.
If you want to use this in Xamarin.Forms, you could use the Dependency Service. https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/dependency-service/introduction
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.