Microsoft Project (MPP) 檔案被廣泛用於管理任務、排程和資源。然而,並非每個人都有MS Project的存取權,這使得分享和分析專案數據變得困難。將 MPP 轉換為 Excel (XLS/XLSX) 提供了更具靈活性和通用性的格式。Excel 的結構化佈局允許用戶過濾、視覺化和自訂專案數據以進行報告和協作。
MPP to Excel Conversion API
GroupDocs.Conversion Cloud SDK for .NET 提供了一個簡單但強大的解決方案,將 Microsoft Project 文件轉換為 Excel 試算表。使用這個 SDK,開發者可以:
- 將 MPP 轉換為 Excel 在線而不安裝 MS Project。
- 保持時間表、任務和依賴關係的準確性。
- 自動化大規模 MPP 到 XLSX 的轉換。
- 直接整合到 .NET 應用程序中。
安裝
您可以從 NuGet 套件管理器安裝 SDK:
Install-Package GroupDocs.Conversion-Cloud
接下來,從 GroupDocs Cloud Dashboard 獲取您的客戶 ID 和客戶密鑰。
您可以考慮訪問以下 tutorial 以獲取有關獲取客戶端憑據的更多詳細信息。
將 MPP 轉換為 Excel 在 C# .NET 中
這裡是如何使用 C# 將 MS Project 數據導出到 Excel 工作簿的步驟:
- 使用客戶端憑證作為參數來創建
Configuration
類的實例。
Configuration configuration = new Configuration(clientId, clientSecret);
- 其次,初始化
ConvertApi
,同時提供 Configuration 物件作為參數。
ConvertApi convertApi = new ConvertApi(configuration);
- 創建
ConvertSettings
類的實例,其中定義了輸入文件名、輸出格式為XLS
以及結果文檔的名稱。
var settings = new ConvertSettings{...}
- 現在,調用 ConvertDocumentRequest API 來執行 MPP 到 Excel 的轉換,並將結果 Excel 保存到雲端存儲。
var response = apiInstance.ConvertDocument(new ConvertDocumentRequest(settings));
// More examples over https://github.com/groupdocs-conversion-cloud/groupdocs-conversion-cloud-dotnet
// 獲取您的 API 憑證
string clientId = "XXXXXX-XXXXXXXXX-4088-9ca0-55c38f4b7f22";
string clientSecret1 = "XXXXXXXXXXXXXXXXXXXX";
// 創建 Configuration 類的實例,並用客戶端 ID 和客戶端密鑰初始化它。
var configurations = new Configuration(clientId, clientSecret1);
// 定義 ApiBaseUrl 的值,以設置 MPP 到 Excel 轉換 API 的基本網址。
configuration.ApiBaseUrl = "https://api.groupdocs.cloud";
// 初始化一個 ConvertApi 類的實例,使用 Configuration 類的物件。
var apiInstance = new ConvertApi(configurations);
// 從本地驅動器載入輸入 MPP
using (var stream = System.IO.File.OpenRead("Home move plan.mpp"))
{
// 創建 FileApi 的實例
var fileUpload = new FileApi(configurations);
// 上傳輸入的 MPP 到雲端儲存。
fileUpload.UploadFile(new UploadFileRequest("input.mpp", stream));
// 創建 ConvertSettings,指定輸入 MPP 的名稱和結果 XLS 文件的名稱。
var settings = new ConvertSettings
{
StorageName = "default",
FilePath = "input.mpp",
Format = "xls",
OutputPath = "converted.xls"
};
// 調用 ConvertDocument 方法進行 MPP 至 Excel 轉換操作。
var response = apiInstance.ConvertDocument(new ConvertDocumentRequest(settings));
if (response != null && response.Equals("OK"))
{
// print success message
Console.WriteLine("MPP to HTML conversion completed successfully !");
}
}

Image:- A preview of MS Project to Excel file conversion.
- 上述範例中使用的樣本 MS Project 可以從 Home move plan.mpp 下載。
Export MS Project to XLSX using cURL
另一種方法是直接使用 REST API 和 cURL 命令將 MPP 文件轉換為 Excel。因此,第一步是生成 JWT 訪問令牌,然後執行以下 cURL 命令以將 Microsoft 項目導出為 Excel 格式。
curl -v "https://api.groupdocs.cloud/v2.0/conversion" \
-X POST \
-H "accept: application/json" \
-H "authorization: Bearer {ACCESS_TOKEN}" \
-H "Content-Type: application/json" \
-d "{ \"StorageName\": \"default\", \"FilePath\": \"{inputMPP}\", \"Format\": \"xls\", \"OutputPath\": \"{resultantXLS}\"}"
Replace:
inputMPP
代表輸入的 MS Project 文件名稱, resultantXLS
代表生成的 Excel 工作簿名稱, ACCESSTOKEN
代表個性化的 JWT 存取令牌。
- 如果您的需求是將結果文件保存在本地驅動器上,請嘗試使用以下命令:
curl -v "https://api.groupdocs.cloud/v2.0/conversion" \
-X POST \
-H "accept: application/json" \
-H "authorization: Bearer {accessToken}" \
-H "Content-Type: application/json" \
-d "{ \"StorageName\": \"default\", \"FilePath\": \"{sourceFile}\", \"Format\": \"xls\"}" \
-o "output.xls"
免費線上 MPP 轉 Excel 轉換器
如果你想在不編碼的情況下試試,請查看 MPP to Excel Converter App。這個免費工具讓你上傳 MPP 文件並立即下載其 Excel 版本。

有用的資源
結論
使用 GroupDocs.Conversion Cloud SDK for .NET 將 MPP 轉換為 Excel 提供了一個安全、自動化和可擴展的項目數據轉換解決方案。無論您是為了報告將 MS Project 輸出為 XLSX,還是將批量轉換集成到企業應用中,這個雲 API 都確保了準確性、靈活性和易用性。
推薦文章
我們強烈建議訪問以下鏈接以了解更多信息: