asp.net µ¼³öExcel
public bool SaveExcel(GridView paramGridView)
{
if (paramGridView.Rows.Count == 0)
{
return false;
}
//´´½¨Excel¶ÔÏó
Microsoft.Office.Interop.Excel.Application myExcel = new Microsoft.Office.Interop.Excel.Application();
myExcel.Application.Workbooks.Add(true);
myExcel.Visible = true;
//Éú³É×Ö¶ÎÃû³ÆÁÐÃû
for (int i = 0; i < paramGridView.Columns.Count; i++)
{
//µÚ¶þÐеڶþÁпªÊ¼Â¼Èë
myExcel.Cells[2, i + 2] = paramGridView.Columns[i].HeaderText;
}
//Ìî³äÊý¾Ý
for (int i = 0; i < paramGridView.Rows.Count; i++)
{
for (int j = 0; j < paramGridView.Columns.Count; j++)
{
if (paramGridView.Rows[i].Cells[j].Text != null)
{
myExcel.Cells[i + 3, j + 2] = "'" + paramGridView.Rows[i].Cells[j].Text.ToString();
}
}
}
return true;
}
protected void btnPrint_Click(object sender, EventArgs e)
{
SaveExcel(grdvMessage);
}
Ïà¹ØÎĵµ£º
ÔÚ¿ª·¢¹ý³ÌÖУ¬Í¨¹ýÃþË÷²é×ÊÁÏ£¬ÊÕ¼¯ÁËһЩֵµÃÌá³öÀ´µÄ¾Ñ飺
1¡¢ Ïà¶ÔÓÚÔÀ´µÄforÓï¾äforeach¾ßÓиüºÃµÄÖ´ÐÐЧÂÊ£¬foreachµÄƽ¾ù»¨·Ñʱ¼äÖ»ÓÐforµÄ30%¡£Í¨¹ý²âÊÔ½á¹ûÔÚforºÍforeach¶¼¿ÉÒÔʹÓõÄÇé¿öÏ£¬ÎÒÃÇÍƼöʹÓÃЧÂʸü¸ßµÄforeach¡£ÁíÍ⣬ÓÃforдÈëÊý¾Ýʱ¼ä´óÔ¼ÊǶÁÈ¡Êý¾Ýʱ¼äµÄ10±¶×óÓÒ£»
2¡¢ ÔÚasp.net³ÌÐòÖУ¬ ......
if (FileUpload1.HasFile)
{
string fileContentType = FileUpload1.PostedFile.ContentType;
&n ......
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="100%" height="100%">
<param name="movie" value="<%= ResolveUr ......
SQL½Å±¾£º
CREATE TABLE tblBooksUpload
(
¡¡DocID int NOT NULL IDENTITY Primary Key ,
¡¡DocTitle varchar (200) ,
¡¡Doc image,
¡¡DocType varchar (50) ,
¡¡Entrydate datetime Default GetDate()
)
Ê×ÏÈÎÒÃÇҪʵÏÖÓû§ÔÚä¯ÀÀÆ÷¶Ë×ÔÓÉÑ¡ÔñÎļþ£¬È»ºóÉÏ´«£¬ÕâÀïÓû§Ñ¡ÔñÎļþ£¬µ±È»ÊÇÒªÇó±ê×¼µÄWindows·½Ê½£ ......
Javascript ÔÚASP.net ĸ°åҳϷÃÎÊ ¿Ø¼þID£º
¶ÔÓÚ html control : Ö±½Ó·ÃÎÊID
document.getElementById("hfRespondID");
¶ÔÓÚ Web control :
document.getElementById("<%= this.hfRespondID.ClientID %>") [×¢Òâ´óСд
]
&nb ......