We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

In-Excel Macros formulas not working with XlsIO Xamarin.Forms

Thread ID:

Created:

Updated:

Platform:

Replies:

129405 Mar 16,2017 02:31 AM Mar 17,2017 08:43 AM Xamarin.Forms 1
loading
Tags: XlsIO
Ramesh GR
Asked On March 16, 2017 02:31 AM

Is Xamarin XlsIO support macro formulas in the imported Excel?

formula is :=VLOOKUP(pt,'Table A'!$C$45:$R$74,14)

I have requirement like..
1. Excel file with extension .xlsm (macro formula supported excel file). Am imported local excel and edited some cell values and get value of another output cell(cell with macro formula) its returns zero value. So here the maraca formula not working.
2. Unable to create new excel using with same local excel the Hangs while "SaveAs" method.


void OnButtonClicked(object sender, EventArgs args)

{


//Debug.WriteLine(annuityInPutEntry.Text);

//Create an instance of ExcelEngine.

using (ExcelEngine excelEngine = new ExcelEngine())

{

//ExcelEngine excelEngine = new ExcelEngine();

IApplication application = excelEngine.Excel;

//application.DefaultVersion = ExcelVersion.Excel2007;


//File path

//PremiumCalculators

//string resourcePath = "SyncfusionExcelDemo.Employee.xlsx";

string resourcePath = "SyncfusionExcelDemo.122L085V03-AYSA.xlsm";//File with marco formulas


//"App" is the class of Portable project.

Assembly assembly = typeof(App).GetTypeInfo().Assembly;

Stream fileStream = assembly.GetManifestResourceStream(resourcePath);


//Opens the workbook

IWorkbook workbook = application.Workbooks.Open(fileStream);


IWorksheet worksheet1 = workbook.Worksheets[0];

IWorksheet worksheet2 = workbook.Worksheets[1];

IWorksheet worksheet3 = workbook.Worksheets[2];

IWorksheet worksheet4 = workbook.Worksheets[3];

IWorksheet worksheet5 = workbook.Worksheets[4];

IWorksheet worksheet6 = workbook.Worksheets[5];


workbook.CalculationOptions.IsIterationEnabled = true;

worksheet1.EnableSheetCalculations();

worksheet2.EnableSheetCalculations();

worksheet3.EnableSheetCalculations();

worksheet4.EnableSheetCalculations();

worksheet5.EnableSheetCalculations();

worksheet6.EnableSheetCalculations();


//Enable the calculation of Excelsheet

ICalculationOptions cal = workbook.CalculationOptions;

cal.RecalcOnSave = true;


Debug.WriteLine("Before edit Sheet1 B55 value =" + worksheet1["C24"].DisplayText);

Debug.WriteLine("Before edit Sheet1 D55 Formula =" + worksheet1["F30"].Formula);

Debug.WriteLine("Before edit Sheet1 D55 value =" + worksheet1["F30"].DisplayText);


//Write the value Pervious value C24 cell

//Output cell F30 : formula isVLOOKUP(pt,'Table A'!$C$45:$R$74,14)

worksheet1["C24"].Number = "50000"; //edit the value



Debug.WriteLine("After edit Sheet1 B55 value =" + worksheet1["C24"].DisplayText);

Debug.WriteLine("After edit Sheet1 D55 Formula =" + worksheet1["F30"].Formula);

Debug.WriteLine("After edit Sheet1 D55 value =" + worksheet1["F30"].DisplayText);


Debug.WriteLine("After edit Sheet1 D55 value =" + worksheet2["C7"].Formula);

Debug.WriteLine("After edit Sheet1 D55 value =" + worksheet2["C7"].DisplayText);


//Create new stream to store workbook copy

MemoryStream stream = new MemoryStream();

workbook.SaveAs(stream); // App hangs when save the changes in new stream


workbook.Close();

excelEngine.Dispose();


//Save the stream into xlsx file

Xamarin.Forms.DependencyService.Get().SaveAndView("Sample1.xlsx", "application/msexcel", stream);


}

}







Sridhar Sukumar [Syncfusion]
Replied On March 17, 2017 08:43 AM

Hi Ramesh, 
 
Thank you for contacting Syncfusion support. 
 
We have tried with shared code snippet and are unable to reproduce the issue. We suspect that issue is reproduced from the “122L085V03-AYSA.xlsm” Excel macro file. We request you to share us the Excel macro file which will be helpful for us to give you a prompt solution at earliest. 
 
Regards, 
Sridhar S.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;