日期:2014-05-18  浏览次数:20505 次

excel出力 乱码问题
HTML code
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Gridview_download.aspx.cs" Inherits="Gridview_download" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



<html xmlns="http://www.w3.org/1999/xhtml" >
<meta http-equiv="content-type" content="application/ms-excel; charset=UTF-8"/>
<head runat="server">
    <title>文件download之Excel出力</title>
    <script type="text/javascript" src='<%=ResolveUrl("~/js/lib/jquery.js") %>'></script>

    <script type="text/javascript" language="javascript">
         // イメージを変更する
       function changeImage(id)
       {   
           if(document.getElementById(id).getAttribute("src",2) == "../Resource/1.png")
           {
           document.getElementById(id).src = "../Resource/0.png";
           $('#'+id + " ~ input").val("0");        
           }
           else
           {
           document.getElementById(id).src = "../Resource/1.png";
           $('#'+id + " ~ input").val("1");
           }
      }
        function setHeader()
         {
            var t = document.getElementById("<%=GridView1.ClientID%>");
            var t2 = t.cloneNode(true);
            for(i = t2.rows.length -1;i > 0;i--){
              t2.deleteRow(i); 
            } 
            t.deleteRow(0); 
            t2.style.width="377px";
            t2.rows[0].cells[2].style.width="137px";
            document.getElementById("div_head").appendChild(t2);
         }

    </script>

</head>
<body>
    <form id="form1" runat="server">
        <div style="height: 310px; width: 400; position: relative; left: 0px; top: 0px;">
            &nbsp;&nbsp;&nbsp;&nbsp;
            <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="一览下载" /><br />
            <br />
            <div id="div_head" style="width: 377;">
            </div>
            <div id="div_info" style="overflow-y: scroll; height: 180px; width: 381px;">
                <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" Width="360px"
                    BackColor="White" BorderColor="Silver" BorderStyle="Solid" BorderWidth="1px"
                    CellPadding="0" ForeColor="Black" GridLines="Vertical">
                    <Columns>
                        <asp:BoundField DataField="NAME" HeaderText="姓名">
                            <HeaderStyle HorizontalAlign="Center" Height="40px" Width="120px" />
                            <ItemStyle HorizontalAlign="Center" Height="35px" Width="120px" />
                        </asp:BoundField>
                        <asp:BoundField HeaderText="团队编号" DataField="TEAM">
                            <HeaderStyle HorizontalAlign="Center" Height="40px" Width="120px" />
                            <ItemStyle HorizontalAlign="Center" Height="35px" Width="120px" />
                        </asp:BoundField>
                        <asp:TemplateField>
                            <HeaderTemplate>