最近用JXL和vba分别做了批量上传图片的小程序,很粗糙,但是我学习中的一小步呀。嘿嘿............... 第一个,jxl实现 public void InsertImageToExcel(String tagetFilePath,String imageFilePath) throws IOException, WriteException{ File tagetFile = new File(tagetFilePath); WritableWorkbook wwb = null; try { wwb = Workbook.createWorkbook(tagetFile); } catch (IOException e1) { System.out.println("Excelファイル作成に失敗する"); System.exit(0); } File file = new File(imageFilePath); File [] fileList = file.listFiles(); File tempFile =new File("C://temp"); tempFile.mkdir(); BufferedImage bfrImage = null; File outFile = null; for(int i=0;i
-1 Then Exit Sub Set FSO = CreateObject("Scripting.FileSystemObject") Set myFolder = FSO.getfolder(.InitialFileName) Set myFiles = myFolder.Files Sheets.Add.Name = "test" Sheets("test").Select For Each oFile In myFiles strName = UCase(oFile.Name) strName = VBA.Right(strName, 3) If strName = "GIF" Then ActiveSheet.Cells(count, 1) = oFile.Name fn = myFolder & "/" & Cells(n, 1) If Dir(fn) <> "" Then Set pif = ActiveSheet.Pictures.Insert(fn) pif.Width = pif.Width * 0.6 pif.Height = pif.Height * 0.6 pif.Top = count * Range("A1").Height pif.Left = Range("A1").Width count = count + CInt((pif.Height + Range("A1").Height * 2) / Range("A1").Height) End If n = n + 1 End If Next End With End Sub
vba 批量插入图片到Excel
最新推荐文章于 2024-06-18 13:59:47 发布