Asp.net GridViewÊý¾Ýµ¼³öµ½Excel£¬Word
Ò»¡¢asp.net DataGridViewµ¼³öµ½ExcelµÄÈý¸ö·½·¨
#region DataGridViewÊý¾ÝÏÔʾµ½Excel
/// <summary>
/// ´ò¿ªExcel²¢½«DataGridView¿Ø¼þÖÐÊý¾Ýµ¼³öµ½Excel
/// </summary>
/// <param name="dgv">DataGridView¶ÔÏó </param>
/// <param name="isShowExcle">ÊÇ·ñÏÔʾExcel½çÃæ </param>
/// <remarks>
/// add com "Microsoft Excel 11.0 Object Library"
/// using Excel=Microsoft.Office.Interop.Excel;
/// </remarks>
/// <returns> </returns>
public bool DataGridviewShowToExcel(DataGridView dgv, bool isShowExcle)
{
if (dgv.Rows.Count == 0)
return false;
//½¨Á¢Excel¶ÔÏó
Excel.Application excel = new Excel.Application();
excel.Application.Workbooks.Add(true);
excel.Visible = isShowExcle;
//Éú³É×Ö¶ÎÃû³Æ
for (int i = 0; i < dgv.ColumnCount; i++)
{
excel.Cells[1, i + 1] = dgv.Columns[i].HeaderText;
}
//Ìî³äÊý¾Ý
for (int i = 0; i < dgv.RowCount - 1; i++)
{
for (int j = 0; j < dgv.ColumnCount; j++)
{
if (dgv[j, i].ValueType == typeof(string))
{
excel.Cells[i + 2, j + 1] = "'" + dgv[j, i].Value.ToString();
}
else
{
excel.Cells[i + 2, j + 1] = dgv[j, i].Value.ToString();
}
}
}
return true;
}
#endregion
#region DateGridViewµ¼³öµ½csv¸ñʽµÄExcel
/// <summary>
/// ³£Ó÷½·¨£¬ÁÐÖ®¼ä¼Ó\t£¬Ò»ÐÐÒ»ÐÐÊä³ö£¬´ËÎļþÆäʵÊÇcsvÎļþ£¬²»¹ýĬÈÏ¿ÉÒÔµ±³ÉExcel´ò¿ª¡£
/// </summary>
/// <remarks>
/// using System.IO;
/// </remarks>
/// <param name="dgv"></param>
private void DataGridViewToExcel(DataGridView dgv)
{
SaveFileDialog dlg = new SaveFileDialog();
dlg.Filter = "Execl files (*.xls)|*.xls";
dlg.FilterIndex = 0;
dlg.RestoreDirectory = true;
dlg.CreatePrompt = true;
dlg.Title = "±£´æΪExcelÎļþ";
if (dlg.ShowDialog() == DialogResult.OK)
{
Stream myStream;
myStream = dlg.OpenFile();
StreamWriter sw = new StreamWriter(myStream, Sy
Ïà¹ØÎĵµ£º
ÔÚWeb±à³Ì¹ý³ÌÖУ¬´æÔÚןܶలȫÒþ»¼¡£±ÈÈçÔÚÒÔÇ°µÄASP°æ±¾ÖУ¬CookieΪ·ÃÎÊÕߺͱà³ÌÕ߶¼ÌṩÁË·½±ã£¬²¢Ã»ÓÐÌṩ¼ÓÃܵŦÄÜ¡£´ò¿ªIEä¯ÀÀÆ÷£¬Ñ¡Ôñ“¹¤¾ß”²Ëµ¥ÀïµÄ“InternetÑ¡Ï¬È»ºóÔÚµ¯³öµÄ¶Ô»°¿òÀïµ¥»÷“ÉèÖÔ°´Å¥£¬Ñ¡Ôñ“²é¿´Îļþ”°´Å¥£¬ÔÚµ¯³öµÄ´°¿ÚÖУ¬¾Í»áÏÔʾӲÅÌÀï ......
ASP.NETÉú³ÉËæ»úÃÜÂë
ÔÚ¿ª·¢ÐèÒªÓû§×¢²áºó²ÅÄÜʹÓÃÌṩµÄ¸÷ÏÄܵÄÓ¦ÓóÌÐòʱ£¬ÔÚÐÂÓû§Ìá½»×¢²áÐÅÏ¢ºó£¬½Ï³£¼ûµÄ×ö·¨ÊÇÓɳÌÐòÉú³ÉËæ»úÃÜÂ룬Ȼºó·¢ËÍÃÜÂëµ½Óû§×¢²áʱÌîдµÄµç×ÓÐÅÏ䣬Óû§ÔÙÓÃÊÕµ½µÄÃÜÂëÀ´¼¤»îÆäÕÊ»§¡£
ʵÏÖASP.NETÉú³ÉËæ»úÃÜÂ빦ÄÜÊǺÜÈÝÒ׵ģ¬ÏÂÃæµÄ´úÂë¸ø³öÁËÍêÕûµÄʵÏÖ·½·¨£º
public static stri ......
ËÄ¡¢ÈçºÎ£ºÏìÓ¦Áбí Web ·þÎñÆ÷¿Ø¼þÖеĸü¸Ä
±¾Ö÷ÌâÖеÄÐÅÏ¢ÊÊÓÃÓÚÈçÏÂÁбí Web ·þÎñÆ÷¿Ø¼þ£ºListBox¡¢DropDownList¡¢CheckBoxList ºÍ RadioButtonList¡£
µ±Óû§ÔÚÁбí Web ·þÎñÆ÷¿Ø¼þÖнøÐÐÑ¡Ôñʱ£¬¿Ø¼þ½«Òý·¢Ò»¸öʼþ£¬Äú¿ÉÒÔÖ±½Ó¶Ô¸Ãʼþ×ö³öÏìÓ¦¡£Í¨³£¸ù±¾²»ÐèÒªÖ±½Ó¶ÔÑ¡Ôñʼþ½øÐÐÏì ......
[ASP.NET]Log4NetÈ«¹¥ÂÔ
ת×Ô:http://blog.5d.cn/vip/icecream/200511/185284.html
ºÜ¶à¿ª·¢Õ߶¼ÏëÒªÒ»¸ö·Ç³£Ç¿´óµÄ³ÌÐòÈÕÖ¾¹ÜÀí¿â£¬Äܹ»Á˽âÓû§¶ÔÓ¦ÓóÌÐòµÄʹÓÃÇé¿ö¡£µ±³ÌÐò³öÏÖÎÊÌâʱ£¬¿ÉÒÔͨ¹ý·ÖÎöÈÕÖ¾À´Á˽âÎÊÌâÖ®ËùÔÚ¡£
¹ýÈ¥ÎÒÃÇ×ÜÊÇÓÃÒ»Öֺܼòµ¥µÄ·½Ê½À´´¦ÀíÈÕÖ¾£¬¼´£ºÊ¹ÓÃÒ»¸öÈÕÖ¾Îļþ£¬µ±³ÌÐòÓÐÎÊÌâʱ¾ ......