<legend id='jgPNz'><style id='jgPNz'><dir id='jgPNz'><q id='jgPNz'></q></dir></style></legend>
<i id='jgPNz'><tr id='jgPNz'><dt id='jgPNz'><q id='jgPNz'><span id='jgPNz'><b id='jgPNz'><form id='jgPNz'><ins id='jgPNz'></ins><ul id='jgPNz'></ul><sub id='jgPNz'></sub></form><legend id='jgPNz'></legend><bdo id='jgPNz'><pre id='jgPNz'><center id='jgPNz'></center></pre></bdo></b><th id='jgPNz'></th></span></q></dt></tr></i><div id='jgPNz'><tfoot id='jgPNz'></tfoot><dl id='jgPNz'><fieldset id='jgPNz'></fieldset></dl></div>
    • <bdo id='jgPNz'></bdo><ul id='jgPNz'></ul>

      <small id='jgPNz'></small><noframes id='jgPNz'>

    1. <tfoot id='jgPNz'></tfoot>

      1. 在 c# 中使用 Microsoft.Office.Interop.Excel 在 excel 列中设置数字、文本和日期

        Set data type like number, text and date in excel column using Microsoft.Office.Interop.Excel in c#(在 c# 中使用 Microsoft.Office.Interop.Excel 在 excel 列中设置数字、文本和日期等数据类型)

          <i id='0W6Zn'><tr id='0W6Zn'><dt id='0W6Zn'><q id='0W6Zn'><span id='0W6Zn'><b id='0W6Zn'><form id='0W6Zn'><ins id='0W6Zn'></ins><ul id='0W6Zn'></ul><sub id='0W6Zn'></sub></form><legend id='0W6Zn'></legend><bdo id='0W6Zn'><pre id='0W6Zn'><center id='0W6Zn'></center></pre></bdo></b><th id='0W6Zn'></th></span></q></dt></tr></i><div id='0W6Zn'><tfoot id='0W6Zn'></tfoot><dl id='0W6Zn'><fieldset id='0W6Zn'></fieldset></dl></div>
              • <small id='0W6Zn'></small><noframes id='0W6Zn'>

              • <legend id='0W6Zn'><style id='0W6Zn'><dir id='0W6Zn'><q id='0W6Zn'></q></dir></style></legend>
              • <tfoot id='0W6Zn'></tfoot>
                  <tbody id='0W6Zn'></tbody>
                  <bdo id='0W6Zn'></bdo><ul id='0W6Zn'></ul>

                  本文介绍了在 c# 中使用 Microsoft.Office.Interop.Excel 在 excel 列中设置数字、文本和日期等数据类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试将数据类型设置为 C# 中的 excel 列,在本例中为数字、文本和日期.

                  I am trying to set the data type to an excel column in C#, in this case the data types number, text and date.

                  如何为整个 excel 列设置格式?

                  How does one set a format to an entire excel column?

                  推荐答案

                  设置文本范围:

                  xlYourRange.NumberFormat = "@";
                  

                  您还可以为您放入单元格的值加上撇号前缀,以将其格式化为文本:

                  You can also prefix a value you put in a cell with an apostrophe for it to format it as text:

                  xlYourRange.Value = "'0123456";
                  

                  将范围设置为数字

                  xlYourRange.NumberFormat = "0";
                  

                  显然,如果您想为整个列设置格式,那么您的范围将是列.

                  Obviously if you want to set the format for the entire column then your range will be the column.

                  xlYourRange = xlWorksheet.get_Range("A1").EntireColumn;
                  

                  日期有点复杂,也取决于您的区域设置:

                  Dates are a bit more complicated and will also depend on your regional settings:

                  // Results in a Date field of "23/5/2011"
                  
                  xlRange.NumberFormat = "DD/MM/YYYY";
                  xlRange.Value = "23/5/2011";
                  
                  // Results in a Custom field of "23/5/2011"
                  
                  xlRange.NumberFormat = "DD-MM-YYYY";
                  xlRange.Value = "23/5/2011";
                  
                  // Results in a Custom field of "05/23/2011"
                  
                  xlRange.NumberFormat = "MM/DD/YYYY";
                  xlRange.Value = "5/23/2011";
                  
                  // Results in a Custom field of "05-23-2011"
                  
                  xlRange.NumberFormat = "MM-DD-YYYY";
                  xlRange.Value = "5/23/2011";
                  
                  // Results in a Date field of "23/05/2011"
                  
                  xlRange.NumberFormat = "DD/MM/YYYY";
                  xlRange.Value = "5/23/2011";
                  
                  // Results in a Custom field of "23-05-2011"
                  
                  xlRange.NumberFormat = "DD-MM-YYYY";
                  xlRange.Value = "5/23/2011";
                  
                  // Results in a Custom field of "23/5/2011"
                  
                  xlRange.NumberFormat = "MM/DD/YYYY";
                  xlRange.Value = "23/5/2011";
                  
                  // Results in a Custom field of "23/5/2011"
                  
                  xlRange.NumberFormat = "MM-DD-YYYY";
                  xlRange.Value = "23/5/2011";
                  

                  这篇关于在 c# 中使用 Microsoft.Office.Interop.Excel 在 excel 列中设置数字、文本和日期等数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  C# namespace alias - what#39;s the point?(C# 命名空间别名 - 有什么意义?)
                  Using Xpath With Default Namespace in C#(在 C# 中使用具有默认命名空间的 Xpath)
                  Generating an EDMX from a DB2 Database(从 DB2 数据库生成 EDMX)
                  IBM .NET Data Provider Connection String issue with Library List(库列表的 IBM .NET 数据提供程序连接字符串问题)
                  .NET DB2 OLEDB pre-requisites(.NET DB2 OLEDB 先决条件)
                  Referring to Code in IBM.Data.DB2 makes that Assembly Unavailable to the rest of my Solution(引用 IBM.Data.DB2 中的代码使该程序集对我的解决方案的其余部分不可用)
                    <tbody id='MO08L'></tbody>
                • <tfoot id='MO08L'></tfoot>

                    <legend id='MO08L'><style id='MO08L'><dir id='MO08L'><q id='MO08L'></q></dir></style></legend>

                    <small id='MO08L'></small><noframes id='MO08L'>

                          <i id='MO08L'><tr id='MO08L'><dt id='MO08L'><q id='MO08L'><span id='MO08L'><b id='MO08L'><form id='MO08L'><ins id='MO08L'></ins><ul id='MO08L'></ul><sub id='MO08L'></sub></form><legend id='MO08L'></legend><bdo id='MO08L'><pre id='MO08L'><center id='MO08L'></center></pre></bdo></b><th id='MO08L'></th></span></q></dt></tr></i><div id='MO08L'><tfoot id='MO08L'></tfoot><dl id='MO08L'><fieldset id='MO08L'></fieldset></dl></div>
                          • <bdo id='MO08L'></bdo><ul id='MO08L'></ul>