我正在使用 C# 代碼在我的組織中的本地服務(wù)器上創(chuàng)建一個(gè)文件 (Excel)。當(dāng)我在服務(wù)器的 IP 之前URI formats are not supported添加“”時(shí),我不斷收到錯(cuò)誤“ ”。http如果我刪除“http自動(dòng)”C://添加“”,則會(huì)導(dǎo)致路徑未找到錯(cuò)誤。有人可以建議一種正確格式化 URL 的方法嗎? string uriPath = "http:\\1.1.1.1\\Test\\Reports-IdH-ls\\Reports\\tes.xlsx"; ExportDSToExcel(DatasetItem, uriPath); ... private void ExportDSToExcel(DataSet ds, string destination) { using (var workbook = SpreadsheetDocument.Create(destination, DocumentFormat.OpenXml.SpreadsheetDocumentType.Workbook)) { var workbookPart = workbook.AddWorkbookPart(); workbook.WorkbookPart.Workbook = new DocumentFormat.OpenXml.Spreadsheet.Workbook(); workbook.WorkbookPart.Workbook.Sheets = new DocumentFormat.OpenXml.Spreadsheet.Sheets(); uint sheetId = 1; foreach (DataTable table in ds.Tables) { // fill table ... } } }
1 回答
慕少森
TA貢獻(xiàn)2019條經(jīng)驗(yàn) 獲得超9個(gè)贊
你可以嘗試以下方法嗎?
string uriPath = "\\\\1.1.1.1\\Test\\Reports-IdH-ls\\Reports\\tes.xlsx";
在 C# 中,如果需要反斜杠,則需要添加另一個(gè)反斜杠對(duì)其進(jìn)行轉(zhuǎn)義,使其成為字面反斜杠。
- 1 回答
- 0 關(guān)注
- 135 瀏覽
添加回答
舉報(bào)
0/150
提交
取消
