Guidance
指路人
g.yi.org
software / rapidq / Examples / File & Directory / qxls / rowtally.bas

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
'This program illustrates how all the .xls files in a directory
'can be read and processed in an automated fashion.
'Usage: rowtally <directory>
'Example: rowtally c:\myxlsfiles
'Output may be redirected to a file
'Example: rowtally c:\myxlsfiles > myxlsfiles.txt
'Thus, a rowtally.bat file might contain numerous directories:
'rowtally c:\xlsfiles1 > xlsfiles1.txt
'rowtally c:\xlsfiles2 > xlsfiles2.txt
'etc
'If the output log file is long, search for "-1" to find file read errors.

     $APPTYPE CONSOLE
     $TYPECHECK ON

     $INCLUDE "RapidQ.inc"
     $INCLUDE "Qxls.inc"

     DIM d$ AS STRING
     DIM ret AS LONG, ws AS LONG, ns AS LONG, maxrow AS LONG
     b=0

     d$=COMMAND$(1)
     IF d$="" THEN PRINT "Usage: rowtally <DirectoryContainingXlsFiles>: Goto ProgEnd
maxrow=0
FileSpec(b) = DIR$(d$+"\*."xls,0): Goto CheckFile
NextFile:
FileSpec(b) = DIR$
CheckFile:
IF FileSpec(b) = "" THEN Goto TallyDone
FileSpec(b)=d$+"\"+FileSpec(b)
ret = xlsOpen
PRINT STR$(ret)+" Sheet(s) "+FileSpec(b)+" "+sERR
'PrintSheetNames: PrintSSTRecords 'remove comment to see internal data
IF ret < 1 THEN Goto FileClose
ns=ret
FOR ws = 1 to ns: maxrow=maxrow+xlsMAXROW(ws)-xlsMINROW(ws)+1: NEXT ws
FileClose:
ret = xlsClose
Goto NextFile

TallyDone:
PRINT "Total Rows = "+STR$(maxrow)
ProgEnd:
END
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Wed 2023-2-1  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2002-12-24 18:42:20