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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Running macros

Thread ID:

Created:

Updated:

Platform:

Replies:

118449 Mar 9,2015 07:30 PM UTC Mar 10,2015 10:28 AM UTC WinRT 3
loading
Tags: XlsIO
matrostik
Asked On March 9, 2015 07:30 PM UTC

Can i able to run macros using Xlsio?

Vikas Sekar [Syncfusion]
Replied On March 10, 2015 06:20 AM UTC

Hi Matrostik,


Currently XlsIO has support only to preserve macros in the excel file. There is no support for running macros using XlsIO. But this requirement can be achieved by converting the macros in to C# code manually.


Please let me know if you have any other concerns.

Regards,
Vikas S



matrostik
Replied On March 10, 2015 06:23 AM UTC

Can i have some example for it?

Thanks.

Vikas Sekar [Syncfusion]
Replied On March 10, 2015 10:28 AM UTC

Hi Matrostik,

Please refer to the below XlsIO code snippets equivalent to the mentioned macro code. XlsIO either directly or by workaround will support most of the functionalities.

Macro Codes

Equivalent C# code using XlsIO

lastRow = [A65536].End(xlUp).Row

    int lastRow = GetXlRowTop(1, 65536, Sheets[0].Range["A65536"].IsBlank, Sheets[0]);

    private int GetXlRowTop(int coloumnIndex, int rowIndex, bool value, IWorksheet sheet)

    {

        for (int row = rowIndex; row >= 1; row--)

        {

            if ((sheet.Range[row, coloumnIndex].IsBlank != value))

            {

                return row;

            }

        }

        return 1;

    }

[A1:D4].ClearContents

    Range["A1:D4"].Clear(ExcelClearOptions.ClearContent);

[D3:DF3].SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=RC[1]"

[3:3] = [3:3].Value

   

    tempRange = Range["D3:DF3"];

    for (int cIndex = tempRange.Column; (cIndex <= tempRange.LastColumn); cIndex++)

    {

       if ((tempRange[3, cIndex].DisplayText == ""))

       {

         tempRange[3, cIndex].FormulaR1C1 = "=RC[1] ";

         tempRange[3, cIndex].Value = tempRange[3, cIndex].CalculatedValue;

       }

    }

[C:C].Replace What:="H/P", Replacement:="PUT"

    tempRangeCol = Worksheet.FindAll("H/P", ExcelFindType.Text);

    if (tempRangeCol != null)

    {

        for (int index = 0; (index  <= (tempRangeCol.Length - 1)); index++)

            {

                if ((tempRangeCol[index].Column == 3))

                {

                    tempRangeCol[index].Value = "PUT";

                }

            }

        }
    }

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 Please let us know if you have any concerns.

Regards,

Vikas



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.

Warning Icon 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.Close Icon

;