Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using System.Text.RegularExpressions;
|
---|
6 |
|
---|
7 | namespace OfficeOpenXml.Utils
|
---|
8 | {
|
---|
9 | /// <summary>
|
---|
10 | /// Class for handling translation between ExcelAddresses and sqref addresses.
|
---|
11 | /// </summary>
|
---|
12 | public static class SqRefUtility
|
---|
13 | {
|
---|
14 | /// <summary>
|
---|
15 | /// Transforms an address to a valid sqRef address.
|
---|
16 | /// </summary>
|
---|
17 | /// <param name="address">The address to transform</param>
|
---|
18 | /// <returns>A valid SqRef address</returns>
|
---|
19 | public static string ToSqRefAddress(string address)
|
---|
20 | {
|
---|
21 | Require.Argument(address).IsNotNullOrEmpty(address);
|
---|
22 | address = address.Replace(",", " ");
|
---|
23 | address = new Regex("[ ]+").Replace(address, " ");
|
---|
24 | return address;
|
---|
25 | }
|
---|
26 |
|
---|
27 | /// <summary>
|
---|
28 | /// Transforms an sqRef address into a excel address
|
---|
29 | /// </summary>
|
---|
30 | /// <param name="address">The address to transform</param>
|
---|
31 | /// <returns>A valid excel address</returns>
|
---|
32 | public static string FromSqRefAddress(string address)
|
---|
33 | {
|
---|
34 | Require.Argument(address).IsNotNullOrEmpty(address);
|
---|
35 | address = address.Replace(" ", ",");
|
---|
36 | return address;
|
---|
37 | }
|
---|
38 | }
|
---|
39 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.