Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/327.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# Microsoft.Office.Interop.Excel.dll-服务器未安装Excel_C#_Excel_Office Interop - Fatal编程技术网

C# Microsoft.Office.Interop.Excel.dll-服务器未安装Excel

C# Microsoft.Office.Interop.Excel.dll-服务器未安装Excel,c#,excel,office-interop,C#,Excel,Office Interop,我正在使用“Microsoft.Office.Interop.Excel.dll”生成Excel文件,而我的部署服务器不允许安装Excel 我知道必须安装Excel,所以我的问题是: 有没有什么方法可以在不安装Excel的情况下部署相同的代码 我知道安装Excel是必须的,所以我的问题是,有没有一种方法可以在不安装Excel或任何其他建议的情况下部署相同的代码 不,必须安装Excel。但你已经知道了,因为这是你开始提问的方式 库的名称(Microsoft.Office.Interop.Excel

我正在使用“Microsoft.Office.Interop.Excel.dll”生成Excel文件,而我的部署服务器不允许安装Excel

我知道必须安装Excel,所以我的问题是:

有没有什么方法可以在不安装Excel的情况下部署相同的代码

我知道安装Excel是必须的,所以我的问题是,有没有一种方法可以在不安装Excel或任何其他建议的情况下部署相同的代码

不,必须安装Excel。但你已经知道了,因为这是你开始提问的方式

库的名称(Microsoft.Office.Interop.Excel.dll)是一个很好的线索。它说互操作,是互操作性的缩写。你不能与不存在的东西进行交互。因此,必须安装Excel才能使用有助于与Excel互操作的DLL

即使你忽略了所有的法律问题,这也没有逻辑意义

如果您确实无法安装Excel,则需要找到其他方法来创建Excel文件。有些库声称这样做,但它们有其局限性。例如:

我知道安装Excel是必须的,所以我的问题是,有没有一种方法可以在不安装Excel或任何其他建议的情况下部署相同的代码

不,必须安装Excel。但你已经知道了,因为这是你开始提问的方式

库的名称(Microsoft.Office.Interop.Excel.dll)是一个很好的线索。它说互操作,是互操作性的缩写。你不能与不存在的东西进行交互。因此,必须安装Excel才能使用有助于与Excel互操作的DLL

即使你忽略了所有的法律问题,这也没有逻辑意义

如果您确实无法安装Excel,则需要找到其他方法来创建Excel文件。有些库声称这样做,但它们有其局限性。例如:

试试这个


此代码来自

您可以将字节数组保存到扩展名为.xls的文件中

private void DumpExcel(DataTable tbl)
        {
            using (ExcelPackage pck = new ExcelPackage())
            {
                //Create the worksheet
                ExcelWorksheet ws = pck.Workbook.Worksheets.Add("Demo");

                //Load the datatable into the sheet, starting from cell A1. Print the column names on row 1
                ws.Cells["A1"].LoadFromDataTable(tbl, true);

                //Format the header for column 1-3
                using (ExcelRange rng = ws.Cells["A1:C1"])
                {
                    rng.Style.Font.Bold = true;
                    rng.Style.Fill.PatternType = ExcelFillStyle.Solid;                      //Set Pattern for the background to Solid
                    rng.Style.Fill.BackgroundColor.SetColor(Color.FromArgb(79, 129, 189));  //Set color to dark blue
                    rng.Style.Font.Color.SetColor(Color.White);
                }

                //Example how to Format Column 1 as numeric 
                using (ExcelRange col = ws.Cells[2, 1, 2 + tbl.Rows.Count, 1])
                {
                    col.Style.Numberformat.Format = "#,##0.00";
                    col.Style.HorizontalAlignment = ExcelHorizontalAlignment.Right;
                }

                //Write it back to the client
                Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                Response.AddHeader("content-disposition", "attachment;  filename=ExcelDemo.xlsx");
                Response.BinaryWrite(pck.GetAsByteArray());
            }
        }
试试这个


此代码来自

您可以将字节数组保存到扩展名为.xls的文件中

private void DumpExcel(DataTable tbl)
        {
            using (ExcelPackage pck = new ExcelPackage())
            {
                //Create the worksheet
                ExcelWorksheet ws = pck.Workbook.Worksheets.Add("Demo");

                //Load the datatable into the sheet, starting from cell A1. Print the column names on row 1
                ws.Cells["A1"].LoadFromDataTable(tbl, true);

                //Format the header for column 1-3
                using (ExcelRange rng = ws.Cells["A1:C1"])
                {
                    rng.Style.Font.Bold = true;
                    rng.Style.Fill.PatternType = ExcelFillStyle.Solid;                      //Set Pattern for the background to Solid
                    rng.Style.Fill.BackgroundColor.SetColor(Color.FromArgb(79, 129, 189));  //Set color to dark blue
                    rng.Style.Font.Color.SetColor(Color.White);
                }

                //Example how to Format Column 1 as numeric 
                using (ExcelRange col = ws.Cells[2, 1, 2 + tbl.Rows.Count, 1])
                {
                    col.Style.Numberformat.Format = "#,##0.00";
                    col.Style.HorizontalAlignment = ExcelHorizontalAlignment.Right;
                }

                //Write it back to the client
                Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                Response.AddHeader("content-disposition", "attachment;  filename=ExcelDemo.xlsx");
                Response.BinaryWrite(pck.GetAsByteArray());
            }
        }

thnx用于解释…生成excel的其他方法是什么,我的意思是没有excel互操作?thnx用于解释…生成excel的其他方法是什么,我的意思是没有excel互操作?