namespace VnToolsAddIns
{
public partial class MyRibbon
{
private void MyRibbon_Load(object sender, RibbonUIEventArgs e)
{
}
public static string RemoveUnicode(string text)
{
string[] arr1 = new string[] { "á", "à", "ả", "ã", "ạ", "â", "ấ", "ầ", "ẩ", "ẫ", "ậ", "ă", "ắ", "ằ", "ẳ", "ẵ", "ặ",
"đ",
"é","è","ẻ","ẽ","ẹ","ê","ế","ề","ể","ễ","ệ",
"í","ì","ỉ","ĩ","ị",
"ó","ò","ỏ","õ","ọ","ô","ố","ồ","ổ","ỗ","ộ","ơ","ớ","ờ","ở","ỡ","ợ",
"ú","ù","ủ","ũ","ụ","ư","ứ","ừ","ử","ữ","ự",
"ý","ỳ","ỷ","ỹ","ỵ",};
string[] arr2 = new string[] { "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a",
"d",
"e","e","e","e","e","e","e","e","e","e","e",
"i","i","i","i","i",
"o","o","o","o","o","o","o","o","o","o","o","o","o","o","o","o","o",
"u","u","u","u","u","u","u","u","u","u","u",
"y","y","y","y","y",};
for (int i = 0; i < arr1.Length; i++)
{
text = text.Replace(arr1[i], arr2[i]);
text = text.Replace(arr1[i].ToUpper(), arr2[i].ToUpper());
}
return text;
}
private void bnt_Click(object sender, RibbonControlEventArgs e)
{
try
{
Excel.Worksheet ActiveWorksheet = Globals.ThisAddIn.Application.ActiveSheet;
Excel.Range ActiveCell = Globals.ThisAddIn.Application.Selection; //Globals.ThisAddIn.Application.ActiveCell;
if (ActiveCell != null)
{
//string aValue = ActiveCell.Value2;
//string sText = ActiveCell.Text;
//ActiveCell.Text = sText.ToUpper();
//System.Windows.Forms.MessageBox.Show(sText.ToUpper() + " - " + ActiveCell.Cells.Count);
//ActiveCell.Offset[0,1].Value2=sText.ToUpper();
foreach (Excel.Range sCell in ActiveCell.SpecialCells(Excel.XlCellType.xlCellTypeConstants))
{
if (sCell.Text != "")
sCell.Value2 = sCell.Text.ToUpper();
}
}
}
catch
{
System.Windows.Forms.MessageBox.Show("Đã có lỗi xảy ra");
}
}