上一页 1 ··· 5 6 7 8 9
  2012年10月25日
摘要: /// <summary> /// 导出Excel /// </summary> /// <param name="table"></param> public void WriteToExcel(DataGridView dgv) { try { SaveFileDialog dialog = new SaveFileDialog { Title = "保存", Filter = "Excel(*.xls)|*.xls|所有文件(*.*)|*.*", RestoreDirectory 阅读全文
posted @ 2012-10-25 13:36 酒歌 阅读(433) 评论(0) 推荐(0)
摘要: string key = "hdyxsjtd";//密匙8个字符 //加密 public string JiaMi(string sourceString) { byte[] keyBytes = Encoding.UTF8.GetBytes(key); byte[] keyIV = keyBytes; byte[] inputByteArray = Encoding.UTF8.GetBytes(sourceString); DESCryptoServiceProvider desProvider = new DESCryptoServiceProvider(); Memo 阅读全文
posted @ 2012-10-25 13:35 酒歌 阅读(274) 评论(0) 推荐(0)
摘要: ushort calc_crc(byte[] str, uint len) { byte i; ushort crc = 0xffff; //string+=4; //从地址位开始计算// int num = 4; while (len-- != 0) { for (i = 0x80; i != 0; i /= 2) { if ((crc & 0x8000) != 0) { crc *= 2; crc ^= 0x1021; } else crc *= 2; if ((str[num] & i) != 0) crc ^= 0x1021; } num++; } return crc 阅读全文
posted @ 2012-10-25 13:33 酒歌 阅读(228) 评论(0) 推荐(0)
摘要: 这里提到了使用DataGridView 去生成三种不同类型的文件,其实生成EXCEL我曾经遇到过三种,希望这些对广大开发者有帮助。并且当中我还列出一些如何通过xls导入到datagridview,很多使用该winform技术的同仁一定很熟悉这种方法。1.首先是如何将数据从 xls文件加载到winform的DataGridView控件中。[csharp] view plaincopyprint?privatevoidbutton1_Click(objectsender,EventArgse){OpenFileDialogfileDLG=newOpenFileDialog();fileDLG.Ti 阅读全文
posted @ 2012-10-25 13:30 酒歌 阅读(452) 评论(0) 推荐(0)
摘要: 字符串转16进制字节数组 Byte[] res = System.Text.Encoding.ASCII.GetBytes(str.ToCharArray());先将str转成字符数组,然后再将字符转成字节。//16进制字符串转为16进制字符数组public static byte[] Hex2ByteArr(string newString) { int len = newString.Length / 2; byte[] arr = new byte[len]; for (int i = 0; i < len; i++) { arr[i] = Convert.ToByte(newSt 阅读全文
posted @ 2012-10-25 13:24 酒歌 阅读(305) 评论(0) 推荐(0)
上一页 1 ··· 5 6 7 8 9