如何自动将当前打开的Excel保存到当前工作目录。 [英] How to auto save my current opened excel to my current working directory.

查看:158
本文介绍了如何自动将当前打开的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);

推荐答案

尝试

try
string path = System.Web.Hosting.HostingEnvironment.MapPath("~/bin/debug");
string workbookPath = System.IO.Path.Combine(path, "Excl.xlsx");


这篇关于如何自动将当前打开的Excel保存到当前工作目录。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆