- Home
- Forum
- Xamarin.Android
- open and read excel
open and read excel
Hi,
I want to open a excel spreadsheet. Read the first column into and array. The sheet name is “SalesPerson”. Can you please give me an example that will work on an android device.
I tried the following
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using System.Collections;
using Syncfusion.XlsIO;
using NU_CRM;
namespace NU_CRM
{
public class GetXdata
{
[System.Security.SecuritySafeCritical]
private ArrayList RepName;
private ArrayList Speciality;
private ArrayList DoctorName;
private ArrayList HospitalName;
private ArrayList ProductName;
String xlDocName = @"/storage/emulated/0/nu-data/data.xlsx";
//string ConfigFile = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "config.xls");
//================== Get reps ===========================
public ArrayList RepaddData()
{
RepName = new ArrayList();
var sheetName = "SalesPerson";
// Existing tab name.
System.IO.MemoryStream mStream = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(xlDocName));
using (ExcelEngine excelEngine = new ExcelEngine())
{
IWorkbook workbook = excelEngine.Excel.Workbooks.Open(mStream);
IWorksheet worksheet = workbook.Worksheets[0];
string cellinfo = worksheet["A1"].Text;
}
return RepName;
}
When I put a breakpoint at string cellinfo = worksheet the value of cell info is "/storage/emulated/0/nu-data/data.xlsx"
SettingsActivity
- Set Linker options to Sdk Assemblies Only
- Add Syncfusion.XlsIO.Portable assembly in Skip Linking assemblies
- 5 Replies
- 5 Participants
-
JV Johnny van Aardt
- Oct 30, 2017 06:24 AM UTC
- Nov 6, 2017 04:29 AM UTC