0

我正在动态创建一个在创建时显示给用户的 Excel 文件,但是我现在还需要将文件保存到服务器上。

如何将其保存到特定文件夹?

我有以下代码

public void ExportMembers()
    {

        Microsoft.Office.Interop.Excel.Application xla = new Microsoft.Office.Interop.Excel.Application();

        Workbook wb = xla.Workbooks.Add(XlSheetType.xlWorksheet);

        Worksheet ws = (Worksheet)xla.ActiveSheet;

        ws.Cells[1, 1] = "Site Id";

       //I create the rest of the cells here

        xla.Visible = true; //this displays the excel spreadsheet to the user

        //client id code is here

                if (!System.IO.Directory.Exists("/Files/" + clientId + "/Excel"))
        { //if doesn't exist make folder

            System.IO.Directory.CreateDirectory("/Files/" + clientId);

            System.IO.Directory.CreateDirectory("/Files/" + clientId + "/Excel");

        }

 //save the xla as a file Here

    }

如何将电子表格保存在服务器上?

任何帮助表示赞赏。

谢谢

4

1 回答 1

1

请参阅 Microsoft.Office.Interop.Excel.Application 的 Save 方法

http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel._application.save

于 2012-08-20T17:16:36.563 回答