Crystal Reports - 组中列的总和(Crystal Reports - Sum of columns in a group)
因此,我创建了以下代码片段,以便在公式中运行,以朗读每个代码在劳动中的工作时间......
NumberVar totalHours := SUM({LaborTicket.HoursWorked}, {LaborTicket.VisualCode}); NumberVar totalMinutes := SUM({LaborTicket.HoursWorked}, {LaborTicket.VisualCode}) * 60 MOD 60; NumberVar totalSeconds := SUM({LaborTicket.HoursWorked}, {LaborTicket.VisualCode}) * 3600 MOD 60; ToText(totalHours, 0) + ":" + ToText(totalMinutes, '00') + ":" + Totext (totalSeconds , '00' )
它将我1.50小时的表示转换为1小时30分钟(或1:30:00),非常漂亮。
然而,现在,他们希望报告由客户端,通过可视代码...
由于我需要在一个组页脚上显示每个可视代码的总小时数,并在另一个组页脚上显示每个客户端的总计,我需要能够根据我不确定如何做的这两个事实来指定汇总。
上面的函数汇总了所有客户端,而不仅仅是报表中该点的那些客户端,因此我需要能够根据可视代码和客户端名称进行汇总。 有什么建议么?
我正在使用Visual Studio 2010附带的水晶版本(安装后你下载的那个)
So I have created the following code snippet to run in a formula to rummate the hours worked for each code in labor...
NumberVar totalHours := SUM({LaborTicket.HoursWorked}, {LaborTicket.VisualCode}); NumberVar totalMinutes := SUM({LaborTicket.HoursWorked}, {LaborTicket.VisualCode}) * 60 MOD 60; NumberVar totalSeconds := SUM({LaborTicket.HoursWorked}, {LaborTicket.VisualCode}) * 3600 MOD 60; ToText(totalHours, 0) + ":" + ToText(totalMinutes, '00') + ":" + Totext (totalSeconds , '00' )
It converts my representation of 1.50 hours into 1 hour and 30 minutes (or 1:30:00), beautiful.
Now however, they want the report to be by client, by visual code...
Since I need to show total hours for each visual code on one group footer and totals for each client on another group footer, I need to be able to specify to summate based on both of those facts which I'm not sure how to do.
The above function summates ALL clients, not just the one at that point in the report so I need to be able to summate based on the visual code AND client name. Any suggestions?
I'm using the version of crystal that comes with Visual Studio 2010 (well the one you download after installing it)
原文:https://stackoverflow.com/questions/6145080
最满意答案
我想如果目录中没有可能与模式匹配的旧文件,则可以将其作为一个命令执行。
TYPE andx.*.txt 2>NUL >>sum_file.txt
或者,这可以构建到.bat脚本中,该脚本在前一个问题中生成.txt文件。 我怀疑你是否想要在命令行上输入所有这些内容。 请注意,这未经过测试。
@ECHO OFF SETLOCAL ENABLEDELAYEDEXPANSION SET "SUM_FILE=xxxxx.txt" IF EXIST "%SUM_FILE%" (DEL "%SUM_FILE%") FOR %%i IN (*.cdf) DO ( andx "%%~i" -o TXT atmos_pressure temp_mean ^ rh_mean wspd_vec_mean wdir_vec_mean ^ org_precip_rate_mean SET EXITCODE=!ERRORLEVEL! IF !EXITCODE! NEQ 0 ( ECHO ERORR: andx failed processing "%%~i" ECHO ERORR: exitcode is !EXITCODE! GOTO TheEnd ) ELSE ( FOR /F "usebackq skip=1 tokens=*" %%s IN (`TYPE "%%~ni.txt"`) DO ( ECHO>>"%SUM_FILE%" %%s ) ) ) :TheEnd EXIT /B %EXITCODE%
I suppose you could do this as one command if the directory is clear of old files that might match the pattern.
TYPE andx.*.txt 2>NUL >>sum_file.txt
Alternatively, this could be built into a .bat script that produces the .txt files in your previous question. I doubt that you would want to type all this on the command line. Please note, this is not tested.
@ECHO OFF SETLOCAL ENABLEDELAYEDEXPANSION SET "SUM_FILE=xxxxx.txt" IF EXIST "%SUM_FILE%" (DEL "%SUM_FILE%") FOR %%i IN (*.cdf) DO ( andx "%%~i" -o TXT atmos_pressure temp_mean ^ rh_mean wspd_vec_mean wdir_vec_mean ^ org_precip_rate_mean SET EXITCODE=!ERRORLEVEL! IF !EXITCODE! NEQ 0 ( ECHO ERORR: andx failed processing "%%~i" ECHO ERORR: exitcode is !EXITCODE! GOTO TheEnd ) ELSE ( FOR /F "usebackq skip=1 tokens=*" %%s IN (`TYPE "%%~ni.txt"`) DO ( ECHO>>"%SUM_FILE%" %%s ) ) ) :TheEnd EXIT /B %EXITCODE%
相关问答
更多-
使用cmd提示脚本和java程序将文件输出定向到txt文件(Directing output of file to txt file using cmd prompt script and java program)[2021-09-27]
我想,你的意思是: @echo off (for /l %%i in (10000,10000,200000) do "my Java program" %%i)>"results.txt" I think, you mean this: @echo off (for /l %%i in (10000,10000,200000) do "my Java program" %%i)>"results.txt" -
对于一个稍微模糊的问题略有模糊的回答。 for /r %%G in (*) do echo %%G 为了得到公正,让我们说.txt文件,使用: for /r %%G in (*.txt) do echo %%G 如果您想添加更多命令,请使用更好的格式: for /r %%G in (*) do ( echo Full path : %%G echo Name/Ext : %%~nxG ) 编辑: 这是一种方法来执行您在评论中提到的内容,将当前目录中的所有文件回显到文本文件: rem ...
-
只需将包含文件名的另一行回显到集合文件即可。 有什么我失踪? for %f in (*.sql) do echo === "%~f" >>file.txt & type "%f" >>file.txt 如果将它放入.bat脚本中,百分号字符必须加倍。 它在多行上更具可读性。 for %%f in (*.sql) do ( echo === "%%~f" >>file.txt type "%%f" >>file.txt ) Just echo another line containing ...
-
首先看看FOR /F命令是如何工作的,从命令行窗口中键入的下一个命令开始(可以使用Copy和Paste : for /F %G in ('dir /b "C:/Users/Silvia/Documents/Roboto\*.txt"') DO @echo %~fG 然后你可以修改你的代码如下: @echo off SETLOCAL color 17 rem download directory set "_pathDownload=C:\Users\Silvia\Documents\Roboto ...
-
cmd < command.txt 当然这取决于command.txt的实际内容。 cmd < command.txt Of course it depends of the real content of command.txt.
-
cmd文件中的通配符(Wildcard in cmd files)[2022-04-09]
您可以尝试迭代所需的文件夹: for %%X in (C:\Users\User1 C:\Users\User2 C:\Users\User3) do (del %%X\Desktop\deleteme.txt ) 要么 for /d %%X in (C:\Users\*) do (del %%X\Desktop\deleteme.txt ) 有一篇很好的文章迭代“为” 更新通过这种方式: for /d %%A in (C:\Users\*) do for /d %%B in (%%A\*) do ec ... -
我想如果目录中没有可能与模式匹配的旧文件,则可以将其作为一个命令执行。 TYPE andx.*.txt 2>NUL >>sum_file.txt 或者,这可以构建到.bat脚本中,该脚本在前一个问题中生成.txt文件。 我怀疑你是否想要在命令行上输入所有这些内容。 请注意,这未经过测试。 @ECHO OFF SETLOCAL ENABLEDELAYEDEXPANSION SET "SUM_FILE=xxxxx.txt" IF EXIST "%SUM_FILE%" (DEL "%SUM_FILE%") ...
-
您是否尝试过使用通配符*: type *.txt Have you tried using the wildcard character *: type *.txt
-
只需将此代码保存到文件夹中的name.bat文件中并运行该命令即可 @echo off setlocal EnableDelayedExpansion set i=0 for %%a in (*.txt) do ( set /a i+=1 ren "%%a" "!i!.new" ) ren *.new *.txt 这里为了避免冲突,首先将文件命名为“.new”扩展,然后将其转换回“.txt”文件。 Just save this code into a name.bat file in yo ...
-
当您使用'a'追加模式打开文件时,操作系统会为您提供一个文件位于文件末尾的文件。 你可以先尝试回到起点,但这取决于你的操作系统是否真的允许: open_pls.seek(0) read_pls = open_pls.read() 您可能希望以'r+'模式打开文件,并在写入时寻找结束。 When you open the file with the 'a' append mode, the OS gives you a file with the file position at the end of th ...