本文介绍了如何自动将当前打开的Excel保存到当前工作目录。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想 - >当我打开excel表时应该自动保存到我当前的工作目录。它的命名总是按照今天这样的日期:sheet462017
我尝试过:
I want-> When I open a excel sheet than it should auto save to my current working directory. and its naming always according to date like Today: sheet462017
What I have tried:
Microsoft.Office.Interop.Excel.Application excelApplication = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook excelWorkBook = excelApplication.Workbooks.Add();
//Microsoft.Office.Interop.Excel.Worksheet wkSheetData = excelWorkBook.ActiveSheet;
string workbookPath = System.IO.Directory.GetCurrentDirectory() + "\\Excl.xlsx";
excelWorkBook.SaveAs(workbookPath);
推荐答案
string path = System.Web.Hosting.HostingEnvironment.MapPath("~/bin/debug");
string workbookPath = System.IO.Path.Combine(path, "Excl.xlsx");
这篇关于如何自动将当前打开的Excel保存到当前工作目录。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!