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.
Syncfusion Feedback

Cell Coordinates conversion

Thread ID:

Created:

Updated:

Platform:

Replies:

123264 Mar 2,2016 08:45 AM UTC Mar 3,2016 09:08 AM UTC WPF 1
loading
Tags: XlsIO
Andrea Perazzolo
Asked On March 2, 2016 08:45 AM UTC

Hi,
I am used to access the cells of a IRange object through the row and column index instead of the Named coordinates (eg A1, B4, A1:B4 etc).
I noticed that in the formulas are always specified with this last format.
There is a builtin function that maps the two coordinate systems ?

     Thanks in advance

    Andrea Perazzolo

Abirami Varadharajan [Syncfusion]
Replied On March 3, 2016 09:08 AM UTC

Hi Andrea,

 Yes, you can set or get the formula for a range in two coordinate system by using FormulaR1C1 property of IRange. Kindly refer the following code example which illustrates this behaviour.

Code Example:

                        

ExcelEngine excelEngine = new ExcelEngine();

IApplication application = excelEngine.Excel;

IWorkbook workbook = application.Workbooks.Create(2);

IWorksheet worksheet = workbook.Worksheets[0];

           

worksheet.Range[1, 1].Value = "10";

worksheet.Range[2, 1].Value = "20";

worksheet.Range[3, 1].Value = "30";

worksheet.Range[4, 1].Value = "40";


worksheet.Range[5, 1].FormulaR1C1 = "=SUM(R[-4]C:R[-1]C)"; // equivalent to "=SUM(A1:A4)"


worksheet.Range[5, 2].Value = "50";

worksheet.Range[6, 2].Formula = "=SUM(A5:B5)";


string formulaR1C1 = worksheet.GetFormula(6, 2, true); //this function returns the string as : "=SUM(R[-1]C[-1]:R[-1]C)"

workbook.Version = ExcelVersion.Excel2013;

workbook.SaveAs("CellCoordinatesSample.xlsx");

workbook.Close();

excelEngine.Dispose();




Please let us know if you have any concerns.

Regards,
Abirami.

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

;