Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Excel:布尔值c的本地名称#_C#_Excel_Localization_Boolean - Fatal编程技术网

C# Excel:布尔值c的本地名称#

C# Excel:布尔值c的本地名称#,c#,excel,localization,boolean,C#,Excel,Localization,Boolean,我想知道Excel如何显示布尔值的名称。例如,如果单元格A1包含true,英文版excel显示“true”,波兰语显示“PRAWDA”。如何以编程方式检查excel如何为用户显示这些值?我认为如果不在本地运行应用程序,就无法获得这些信息。如果有,我想知道怎么做 在本地运行Excel可以使用以下代码获取本地化字符串: using System; using MSExcel = Microsoft.Office.Interop.Excel; using System.Runt

我想知道Excel如何显示布尔值的名称。例如,如果单元格A1包含true,英文版excel显示“true”,波兰语显示“PRAWDA”。如何以编程方式检查excel如何为用户显示这些值?

我认为如果不在本地运行应用程序,就无法获得这些信息。如果有,我想知道怎么做

在本地运行Excel可以使用以下代码获取本地化字符串:

    using System;
    using MSExcel = Microsoft.Office.Interop.Excel;
    using System.Runtime.InteropServices;

    static void Main(string[] args)
    {
        MSExcel.Application excel = null;
        MSExcel.Worksheet sheet = null;
        string localizedFalse;
        string localizedTrue;

        try
        {
            excel = new MSExcel.Application();
            excel.DisplayAlerts = false;
            sheet = (MSExcel.Worksheet)excel.Workbooks.Add(MSExcel.XlWBATemplate.xlWBATWorksheet).Sheets.Add();
            sheet.Cells[1, 1] = false;
            sheet.Cells[1, 2] = true;
            sheet.Columns.AutoFit(); //If the localized string doesn't fit in the default column width, the returned text will be ##########.
            localizedFalse = sheet.Cells[1, 1].Text;
            localizedTrue = sheet.Cells[1, 2].Text;

            Console.WriteLine("Excel localized true: {0} \r\nExcel localized false: {1}", localizedTrue, localizedFalse);
            Console.ReadLine();
        }
        finally
        {
            if (sheet != null)
            {
                Marshal.ReleaseComObject(sheet);
            }

            if (excel != null)
            {
                excel.Quit();
                Marshal.ReleaseComObject(excel);
            }
        }
    }

毫无疑问,作为微软,它只使用<代码> toStrug()/代码>,如果没有Excel源代码,很难说,你可以写“代码>”“真”<代码>(前面有一个引号),Excel将把内容视为纯文本,没有将其更改为特定于语言的布尔语我想知道是否有任何方法可以不用向工作表中写入内容就可以做到这一点。但是这个答案也很好,谢谢!