Tag: 下载

用于https资源的Excel VBA URLDownloadToFile错误

我尝试使用VBA从Excel中的服务器下载文件。 这在使用http时可以正常工作,但不能使用https。 我可以在Internet Explorer中同时访问两个地址(http / https)。 如果我使用URLDownloadToFile与http地址下载文件。 当使用https地址,我得到的返回码-2146697211。 也许这是一个证书问题? 干杯, 弗雷德里克 码: Private Declare Function URLDownloadToFile Lib“urlmon”_ 别名“URLDownloadToFileA”(ByVal pCaller只要,_ ByVal szURL作为string,ByVal szFileName作为string,_ ByVal dwReserved As Long,ByVal lpfnCB As Long)As Long Dim Ret As Long Sub DownloadCode() Dim strURL As String 昏暗的strPath作为string strURL =“https:/url.de/module.bas” strPath = Environ(“TEMP”)&“\ Module.bas” Ret = URLDownloadToFile(0,strURL,strPath,0,0) 如果Ret = 0那么 “MsgBox”文件成功下载“ 其他 […]

导出使用HttpContext.Current.Response是造成问题

我正在开发一个使用asp.net/C#/HTML5/bootstrap的网站。 其中一个要求是将文档导出为Excel和/或PDF。 我能够导出(成功)使用以下代码片段(这是Excel代码段): HttpContext.Current.Response.ContentType = "application/octet-stream"; HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8; HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=" + filename); HttpContext.Current.Response.BinaryWrite(xlsBytes); HttpContext.Current.Response.Flush(); HttpContext.Current.Response.End(); 我遇到的问题是,在运行之后,似乎是停止页面生命周期中的轨道。 作为一个例子,用户点击导出button,调用JavaScript抛出一个“请稍候”模式对话框,并提交表单: <script src="../Scripts/waitingFor.js"></script> <script type="text/javascript"> function pleaseWait() { waitingDialog.show("Building File<br/>…this could take a minute", { dialogSize: "sm", progressType: "warning" }); form = document.getElementById("frm_contentMaster"); form.submit(); } </script> javascript包含文件: /** * Module for displaying "Waiting for…" dialog using Bootstrap […]

下载从spring MVC控制器(Ajax调用)返回的excel文件

我正在开发一个弹簧引导,springmvc的Web应用程序。 我有一个控制器方法,返回一个excel文件如下: in = new FileInputStream(comparsionreport); out = response.getOutputStream(); response.setHeader("Content-disposition", "attachment; filename=" + comparsionreport.getName()); response.setContentType("application/vnd.ms-excel"); response.addHeader("filename", comparsionreport.getName()); byte[] buffer = new byte[BUFFER_SIZE]; // use bigger if you want int length = 0; while ((length = in.read(buffer)) > 0) { out.write(buffer, 0, length); } in.close(); out.close(); 在视图(jaavscript)中,AJAX调用完成如下: $.ajax({ url : $('#compareFrm').attr('action'), type : 'post', responseType: "arraybuffer", […]

使用Python从Box下载文件

我正在尝试使用Python将Excel文件从Box下载到我的本地驱动器。 使用boxsdk,我可以通过OAuth2进行身份validation,并成功获取Box上的文件ID。 但是,当我使用client.file(file_id).content()函数,它只是返回一个string,如果我使用client.file(file_id).get()那么它只是给了我一个boxsdk.object.file.File 。 有人知道如何将其中的任何一个写入本地机器上的Excel文件? 或者使用Python从Box下载excel文件的更好的方法。 (我发现boxsdk.object.file.File有一个选项download_to(writeable_stream 这里,但我不知道如何使用它来创build一个Excel文件,我的search没有帮助)。

Excel VBA从url下载文件

我正在尝试构build一个Excel VBA命令,它将自动执行以下操作: 从已经制作好的excel电子表格中导入另一个excel wordbook的列表,其中的项目将与相应的列匹配(即识别地址,邮政编码等,并将它们分配到包含地址,邮政编码等的列) 从邮编列表(列)复制粘贴子9,999行,并在线粘贴到以下URL( http://imd-by-postcode.opendatacommunities.org/ )) 然后,将这些值粘贴到文本框区域后,我想按下“获取剥夺数据”button,然后下载创build的xlsx文件 下载的Excel工作簿将被打开,所有信息将复制/粘贴到我的原始工作簿上的特定空白工作表中 重复此function,直到所有子9999行都完成(即如果我有3万行的数据这样做了3次) 到目前为止,我已经开始做的是第2步和第3步,我已经设法复制粘贴到文本框区域的值,并“按”获取剥夺数据“button,但我堆放在如何下载生成的xlsx由下一页上的网站创build的文件。 我正在使用的代码如下,但是在下载文件时我总是收到错误: Sub papafi_1_command() Dim ie As Object Dim MyURL As String Set ie = CreateObject("InternetExplorer.Application") 'create new instance of IE. use reference to return current open IE if 'you want to use open IE window. Easiest way I know of is via title bar. […]

在IE 11中下载Excel文件

我有这个ExtJS代码,用于将网格数据转换为Excel格式并写入文件,代码将最终将网格数据导出到可下载的Excel文件中。 这在firefox和chrome中效果很好,但在IE浏览器(IE 11)中无法运行。 经分析发现,代码最终会将下面的string张贴到URL下拉框中,该框将下载excel文件。 data:application/vnd.ms-excel;base64,<base64 encoded string follows here> 起初,我认为问题可能在代码中的某个地方,然后我碰巧检查下面的步骤。 如果我在Chrome或Firefox中粘贴下面的内容,它会提示文件下载并下载一个虚拟文件。 data:application/vnd.ms-excel;base64,blahblahblahblahblah 但是,如果我粘贴在IE 11上面的相同的string,它什么都不做。 所以我在假设代码工作正常,但我可能不得不做更多的东西,使其兼容IE浏览器。 但我不知道还有什么我可以尝试。 任何指针深表赞赏。 下面是我的ExtJS代码,如果有帮助。 //here xmlString has the constructed xml string which holds //grid column headers + grid rows with Table, Column, Cell and Worksheet tags. var ctx = { created : (new Date()).getTime(), worksheets : xmlString }; var uri = […]

GWT下载Excel .xlsx给我一个损坏的文件

在我工作的团队中,我正在开发一个GWT应用程序,它使公司中的每个团队都了解他们必须做的事情。 该程序正在工作,但现在我们希望您可以下载的Excel表格将是一个* .xlsx而不是一个xls这个整个项目对我来说是新的,我认为自己作为GWT的初学者。 在代码中为Exceltable提供文件名时,最后有一个+“。xls”。 但是,当我改变它+“。xlsx”和testing应用程序的下载仍然工作,但是当我尝试在Excel中打开该文件时,它显示了一个错误消息,并告诉我该文件已损坏? (.xls作品) 你能解释一下如何使用一个serverSite生成的Excel在GWT下载工作? 也许你有一些想法是什么导致文件被损坏(可惜这个应用程序的程序员在假期,所以我不能问他…) 提前致谢 编辑: public class Download extends HttpServlet { private static final long serialVersionUID = 5580666921970339383L; @Override public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request, response); } @Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String filename = (String)request.getSession().getAttribute(CrossReportConstants.ATTR_FILENAME); byte[] data = […]

下载的本地.xlsx文件无法打开(AngularJS和Javascript)

我创build了一个button来下载位于前端的test-report.xlsx。 具有正确名称的文件将下载,但是,它不会打开。 正常的文件大约是10MB,但通过button下载后的文件大约是6MB。 下载时需要对xlsx文件做些什么吗? 编辑:当点击文件时,我从数字中得到以下错误: "test-report.xlsx” can't be opened right now. Numbers couldn't read the file. 我的代码: <md-button target="_self" href="files/test-report.xlsx" download="test-report.xlsx"> Download Report </md-button>

通过JSF操作方法下载Excel文件会导致一些奇怪的字符被前置,并且完整的JSP页面被追加

我正在使用JSF和在一个托pipe的bean(视图范围)我有一个方法为: public String viewReport() { HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse(); response.setContentType("application/vnd.ms-excel"); response.setHeader("Content-Disposition","attachment;filename=book1.xls"); try { File file = new File("C:\\soheb\\book1.xls"); FileInputStream fileIn = new FileInputStream(file); ServletOutputStream out = response.getOutputStream(); byte[] outputByte = new byte[4096]; //copy binary contect to output stream while(fileIn.read(outputByte, 0, 4096) != -1) { out.write(outputByte, 0, 4096); } fileIn.close(); out.flush(); out.close(); } catch(IOException e) […]

无法获得全名,当我尝试下载一个Excel

当我尝试下载一个文件的全名,它没有得到下载。 但在一个参数中发送参数作为文件名。 文件path是自动生成的。 正在下载文件名是:Update_4_Product(显示在屏幕截图中) 实际的文件名是:Update_4_Product Details.xlsx 这是我的代码 private void DownloadUploadDataTemplate(string fileName) { string Outgoingfile = fileName + ".xlsx"; string targetDirectory = Path.GetDirectoryName(XTP.Caching.AppSettingCache.GalleryFilePath) + @"\" + this.TenantCode + "\\Files" + @"\" + Outgoingfile; System.IO.FileInfo file = new System.IO.FileInfo(targetDirectory); if (file.Exists) { Response.Clear(); Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name); Response.AddHeader("Content-Length", file.Length.ToString()); Response.ContentType = "application/vnd.ms-excel"; Response.WriteFile(file.FullName); HttpContext.Current.ApplicationInstance.CompleteRequest(); } else […]