Excel名称保存为唯一名称 [英] Excel name saving as a Unique name

查看:125
本文介绍了Excel名称保存为唯一名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我正在将Excel数据上传到SQL DB,因为我正在做所有的事情,它工作得很好对我而言......



现在,我的问题是每当我上传不同的excel文件时,我想保存任何具有唯一名称的excel。 。



Ex:



我试着上传A.xls,B.xls。 ..,但文件应保存在xxx.xls文件夹中。



这是保存excel的代码



 FileName = Path.GetFileName(FileUpload1.PostedFile.FileName); 
string Extension = Path.GetExtension(FileUpload1.PostedFile.FileName);
string FolderPath = ConfigurationManager.AppSettings [ DMSFolder];
FilePath = Server.MapPath(FolderPath + FileName);
ViewState [ FilePath] = FilePath;
ViewState [ FileName] = FileName;
FileUpload1.SaveAs(FilePath);





如何实现这个目标....



但是在保存文件之后还有一件事我想在那个excel中显示可用的工作表。所以,无论我们实施什么,它都不会影响现有的......



可以任何机构给我一些建议...



在此先感谢....

解决方案

您可以继续添加日期和时间(或序列号)使文件名唯一。

GUID [ ^ ]将是最独特的项目(但我想这对你的要求来说太过分了。)

Hi,

I''m doing Excel Data Upload into SQL DB, for this i''m doing all the stuff, it''s working fine for me also...

Now , my question is whenever i upload the different excel file''s , i want to save any excel having a unique name...

Ex:

I''m try to upload A.xls,B.xls..., but the file should be saved in folder as xxx.xls.

this is the code for saving the excel

FileName = Path.GetFileName(FileUpload1.PostedFile.FileName);
string Extension = Path.GetExtension(FileUpload1.PostedFile.FileName);
string FolderPath = ConfigurationManager.AppSettings["DMSFolder"];
FilePath = Server.MapPath(FolderPath + FileName);
ViewState["FilePath"] = FilePath;
ViewState["FileName"] = FileName;
FileUpload1.SaveAs(FilePath);



How to achieve this ....

But one more thing after save the file i want to display the available sheets in that excel . so, whatever we implement for that it''s wont effect to existing ...

can any body give me some suggestion...

Thanks in Advance....

解决方案

You could go ahead and add date and time (or a serial number) to make the file name unique.
A GUID[^] would be the most unique item (but I guess that would be overkill for your requirement).


这篇关于Excel名称保存为唯一名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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