public class StringUtil{private static readonly string[] VietnameseSigns = new string[]{"aAeEoOuUiIdDyY","áàạảãâấầậẩẫăắằặẳẵ","ÁÀẠẢÃÂẤẦẬẨẪĂẮẰẶẲẴ","éèẹẻẽêếềệểễ","ÉÈẸẺẼÊẾỀỆỂỄ","óòọỏõôốồộổỗơớờợởỡ","ÓÒỌỎÕÔỐỒỘỔỖƠỚỜỢỞỠ","úùụủũưứừựửữ","ÚÙỤỦŨƯỨỪỰỬỮ","íìịỉĩ","ÍÌỊỈĨ","đ","Đ","ýỳỵỷỹ","ÝỲỴỶỸ"};public static string RemoveSign4VietnameseString(string str){//Tiến hành thay thế , lọc bỏ dấu cho chuỗifor (int i = 1; i < VietnameseSigns.Length; i++){for (int j = 0; j < VietnameseSigns[i].Length; j++)str = str.Replace(VietnameseSigns[i][j], VietnameseSigns[0][i - 1]);}return str;}}
Showing posts with label C#. Show all posts
Showing posts with label C#. Show all posts
Loại bỏ dấu tiếng việt trong C# (How to remove Vietnamese characters by C#)
Print by capture image in C# on window form
Code detail ...
// name space
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Printing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
private System.IO.Stream streamToPrint;
string streamType;
[System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")]
private static extern bool BitBlt
(
IntPtr hdcDest,
int nXDest,
int nYDest,
int nWidth,
int nHeight,
IntPtr hdcSrc,
Import data from Excel to Gridview on Window form
Introduction
This article will help you understand how to Import data from excel to gridview by use OdbcDataAdapter
Code detail for button Click
openFileDialog.Filter = "Excel 2007 (*.xlsx)|*.xlsx|Excel 2003 (*.xls)|*.xls";openFileDialog.Title = "Open file Excel";
openFileDialog.InitialDirectory = @"C:\";
openFileDialog.ShowHelp = true;
if (openFileDialog.ShowDialog()== DialogResult.OK)
{
string strConnection;
strConnection = @"Dsn=Excel Files;dbq=" + openFileDialog.FileName+ ";driverid=1046;maxbuffersize=2048;pagetimeout=5";
OdbcDataAdapter Adapter = new OdbcDataAdapter("SELECT* FROM [" + "newSheet1" +"$]",strConnection);
DataSet ds =new DataSet();
Adapter.Fill(ds, "ExcelInfo");
Subscribe to:
Posts (Atom)