using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions; namespace OfficeOpenXml.Utils { /// /// Class for handling translation between ExcelAddresses and sqref addresses. /// public static class SqRefUtility { /// /// Transforms an address to a valid sqRef address. /// /// The address to transform /// A valid SqRef address public static string ToSqRefAddress(string address) { Require.Argument(address).IsNotNullOrEmpty(address); address = address.Replace(",", " "); address = new Regex("[ ]+").Replace(address, " "); return address; } /// /// Transforms an sqRef address into a excel address /// /// The address to transform /// A valid excel address public static string FromSqRefAddress(string address) { Require.Argument(address).IsNotNullOrEmpty(address); address = address.Replace(" ", ","); return address; } } }