Tag: 文件

为每个filter结果创build一个单独的excel文件

我有一个电子表格,我想拆分为每个部门分开的电子表格,有更多的部门显示,我希望每个.xls文件保存与部门名称 部门领域是专栏D. 即我想每个.xls文件只有部门1,部门2,等等的logging。 不幸的是,我无法发布电子表格的屏幕截图,因为我的代表还不够好。 我会用什么VBA代码来做到这一点?

macros:如何浏览excel文件并读取数据

我正在写3个步骤的macros脚本: 通过浏览读取excel文件 – 转换为xml格式 – 通过浏览将xml文件导出到某个path。 我知道如何通过浏览alrady导出。 Set objShell = CreateObject("Shell.application") Set objFolder = objShell.BrowseForFolder(0, "choose the path you want to export the xml file", 0, 0) 但这一个是浏览文件夹。 如何浏览文件? 如果我想通过浏览导入excel数据? 谢谢

优化或加速从.xy文件读取到excel

我有几个.xy文件(2列x和y值)。 我一直在尝试读取所有这些文件,并将“y”值粘贴到一个excel文件中(所有这些文件中的“x”值是相同的)。 我到目前为止的代码逐个读取文件,但它非常慢(每个文件大约需要20秒)。 我有相当多的.xy文件,时间大大增加。 我到现在为止的代码是: import os,fnmatch,linecache,csv from openpyxl import Workbook wb = Workbook() ws = wb.worksheets[0] ws.title = "Sheet1" def batch_processing(file_name): row_count = sum(1 for row in csv.reader(open(file_name))) try: for row in xrange(1,row_count): data = linecache.getline(file_name, row) print data.strip().split()[1] print data ws.cell("A"+str(row)).value = float(data.strip().split()[0]) ws.cell("B"+str(row)).value = float(data.strip().split()[1]) print file_name wb.save(filename = os.path.splitext(file_name)[0]+".xlsx") except IndexError: […]

拆分文本到行excel

我有一个VBA代码,我将一个txt文件导入到一个单元格中。 这是代码(这不是那么重要): Sub ReadFile() ' Requires a reference to Microsoft Scripting Runtime (Tools > References) Dim FSO As FileSystemObject Dim FSOFile As File Dim FSOStream As TextStream Dim Rand Dim ws As Worksheet Set ws = Worksheets("Sheet1") Set FSO = New FileSystemObject Set FSOFile = FSO.GetFile("C:\Users\sdagfsgedg\Desktop\20121122.log") Set FSOStream = FSOFile.OpenAsTextStream(ForReading, TristateUseDefault) Rand = 1 Do […]

VB6 – 无法完整读取Excel文件

无论我尝试什么方法(目前我正在使用Scripting.FileSystemObject),我只是不能正确读取这个XLS文件。 这是我的代码(我不想读取单元格,我想读取文件,就好像它是一个文本文件) Dim fso As New FileSystemObject Dim f As File Dim fsoStream As TextStream Dim strLine As String Set f = fso.GetFile("C:\Users\Admin\Desktop\ara\DOSYA.xls") Set fsoStream = f.OpenAsTextStream(ForReading) Do While Not fsoStream.AtEndOfStream strLine = fsoStream.ReadLine Text1.Text = Text1.Text & strLine Loop fsoStream.Close Set fsoStream = Nothing Set f = Nothing Set fso = Nothing 我得到的只是该文件的前5-6个字符,然后再多一点乱码,就是这样。 如果我在Excel中打开它工作正常。

如何提高缓慢读取文件的VBAmacros

在最近的一个项目中,我需要从包含大约5K行的文件中读取。 每行都有不同的字段,我需要将其中的一些收集到Excel中的特定单元格中。 一行的例子: DATA1; DATA2; DATA3; …..; dataN \ r N可以达到600。 目前我正在打开文件,并通过每一行循环,分裂“;” 并保存。 我需要的是一个例子: avarSplit = Split(sBuf, ";") Range("C" & i).Value = CDbl(avarSplit(meter)) 这往往是非常缓慢的,我已经有了, Application.Calculation = xlCalculationManual

Excel VBA无法保存包含variables保留date值的文件名

我有一些代码将当前工作表复制并粘贴到一个空白的新工作簿,然后根据某些单元格(存储在variables中)的值进行保存。 具体来说,这些是网站,客户和访问date。 这一切都与网站和客户端正常工作,但是,当我在文件名中包含datevariables保存,它会引发错误:运行时错误76 – 找不到path。 我会很感激任何帮助/build议。 Sub Pastefile() Dim client As String Dim site As String Dim visitdate As String client = Range("B3").Value site = Range("B23").Value screeningdate = Range("B7").Value Dim SrceFile Dim DestFile SrceFile = "C:\2013 Recieved Schedules\schedule template.xlsx" DestFile = "C:\2013 Recieved Schedules" & "\" & client & " " & site & " […]

(Excel 2010)超链接到与xlsx文件相同的目录中的文件

我想添加一个超链接到Excel单元格,导致与xlsx文件在同一目录中的文件。 我用这个做到了 =HYPERLINK("file.ext") 但细胞看起来像这样 file.ext (like link, blue and underlined) 我想input其他的东西,例如 Click here (like link, blue and underlined) 我知道我可以使用“插入”选项卡的常规超链接来做到这一点,但我想用HYPERLINK函数或其他函数来做到这一点。

VBAmacros来validation新文件是创build还是添加到文件夹

我不确定这个问题是否已经在这里提出。 我搜查了很多(!),没有find答案。 我想在VBA中创build一个macros来每天检查一个特定的文件夹,如果有新的文件添加的话。 我已经看到了一些代码来检查文件是否存在(给定名称),但我真的很难find我的问题的答案。 谁能帮我这个?

读取上传的Excel文件而不保存

在这段代码中,我从用户那里获取上传的文件,并将其保存在我的应用程序的一个文件夹中,然后将OleDbConmnection创build为这个Excel文件并读取数据。 我的问题是 – 可以有人build议一种方式,是阅读这个excel文件的首选,但没有保存一次又一次,因为它在我的情况下填充数据与数据 if (Request != null) { HttpPostedFileBase file = Request.Files[0]; if ((file != null) && (file.ContentLength > 0) && !string.IsNullOrEmpty(file.FileName)) { string fileName = file.FileName; string fileContentType = file.ContentType; string fileExtension = System.IO.Path.GetExtension(Request.Files[0].FileName); if (fileExtension == ".xls" || fileExtension == ".xlsx") { string fileLocation = Server.MapPath("~/Content/") + Request.Files[0].FileName; if (System.IO.File.Exists(fileLocation)) { System.IO.File.Delete(fileLocation); […]