在Excel中不到第12天,远程网站日和月反转?

时间:2011-02-17 07:59:52

标签: c# asp.net ms-office office-interop

本地机器视觉工作室日和月是正常的格式dd / mm / yyyy。 但是在部署到远程网站后,使用C#保存的Excel,不到第12天,就变成了mm / dd / yyyy。

实际上,代码是从存储过程中将数据导入Excel,这些存储过程会进行数据透视表

我将日期保存到单元格的方式是

oSheet.Cells[currentline, i + 1] = String.Format("{0:dd-MM-yyyy}", Convert.ToDateTime(reader[i].ToString()));

while (reader.Read())
{
    for (int i = 0; i < reader.FieldCount; i++)
    {
        if (reader[i] != System.DBNull.Value)
        {
            if (i == 0)
            {
                oSheet.Cells[currentline, i + 1] = String.Format("{0:dd-MM-yyyy}", Convert.ToDateTime(reader[i].ToString()));

            }
            else
                oSheet.Cells[currentline, i + 1] = reader[i].ToString();
        }
    }
    currentline = currentline + 1;
}
reader.Close();

        <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly>
                <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>
                <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>
                <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
            </dependentAssembly>
        </assemblyBinding>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Office.Interop.Excel"
        publicKeyToken="71e9bce111e9429c"
        culture="neutral" />
        <publisherPolicy apply="yes" />
        <bindingRedirect oldVersion="12.0.0.0"
        newVersion="11.0.0.0"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

1 个答案:

答案 0 :(得分:0)

我添加后解决了 UICulture = asp中的“en”Culture =“en-GB”