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