在报表中加粗总计行的任何方法



我正在使用 bash 脚本为高级管理人员生成报告,并在 cronjob 的帮助下通过邮件发送,但我的问题是我们需要粗体格式Grand_Total行。

我通过以下多个查询获得结果:

mysql -H -u$DBUSER -p$DBPASS test -e "SELECT IFNULL(cust_name,'Grand_Total') AS cust_name,SUM(order_amt) AS amt FROM mytable1 GROUP BY cust_name WITH ROLLUP;" > REPORT_FILE.txt
mysql -H -u$DBUSER -p$DBPASS test -e "SELECT IFNULL(cust_name,'Grand_Total') AS cust_name,SUM(order_amt) AS amt FROM mytable2 GROUP BY cust_name WITH ROLLUP;" >> REPORT_FILE.txt
mysql -H -u$DBUSER -p$DBPASS test -e "SELECT IFNULL(cust_name,'Grand_Total') AS cust_name,SUM(order_amt) AS amt FROM mytable3 GROUP BY cust_name WITH ROLLUP;" >> REPORT_FILE.txt

它将在REPORT_FILE.txt文件中生成 html 格式的输出。

我想通过 mysql 查询(如果有办法,根据我的说法,mysql 中没有办法)或在借助任何 linux 命令将数据导出到 txt 文件中后,将我的"Grand_Total"行加粗。

您需要使用其他脚本语言(如Python,Perl等)读取文件,并且可以根据需要解析文件并更改所需的列。

您甚至可以使用 sed 或 awk 来编辑您想要的 sepcific 列。

最后我通过下面的perl脚本得到了解决方案,所以首先我的脚本将在mytext.txt文件中生成报告,然后这个perl脚本将在每行中搜索"TD"单词,但在<TD>Grand Total</TD>到行尾之间,并将其替换为" TH"后将其打印到myoutput.txt文件以及没有这些关键字的行。因此,最后我的总计行将在报告中显示为粗体。

#!/usr/local/bin/perl
use strict;
use warnings;
open (INPUTFILE, "mytext.txt") or die ("Unable to find the file");
open (OUTFILE, ">myoutput.txt") or die ("Unable to find the file");
my @lines = <INPUTFILE>;
foreach my $str (@lines) {
        if (my ($matches) = $str =~ /(<TD>Grand Total</TD>(<TD>-?[0-9.]+</TD>)*)/) {
                my $orig = $matches;
                $matches =~ tr/TD/TH/ ;
                $str =~ s/$orig/$matches/;
                print OUTFILE $str;
        }else{
                print OUTFILE $str;
        }

}


我的文本.txt康特如下-

<br><br>Shoes Bulk Inventory Report <br><br>
<TABLE BORDER=1><TR><TH>Shoes</TH><TH>size 6</TH><TH>size 7</TH><TH>size 8</TH><TH>size 9</TH><TH>size 10</TH><TH>size 11</TH><TH>LastDay_Total</TH><TH>Today_Total</TH><TH>Quantity Change</TH><TH>% Change</TH></TR><TR><TD>Marco ferro Boot - Black - 198747</TD><TD>0</TD><TD>40</TD><TD>143</TD><TD>301</TD><TD>23</TD><TD>0</TD><TD>556</TD><TD>507</TD><TD>-49</TD><TD>-8.81</TD></TR><TR><TD>Lotto Marathon Shoes White Navy - 196553</TD><TD>2</TD><TD>410</TD><TD>105</TD><TD>26</TD><TD>152</TD><TD>0</TD><TD>705</TD><TD>695</TD><TD>-10</TD><TD>-1.42</TD></TR><TR><TD>LOTTO MAGIC SHOES - Blue - 196552</TD><TD>51</TD><TD>224</TD><TD>644</TD><TD>1925</TD><TD>698</TD><TD>0</TD><TD>3672</TD><TD>3542</TD><TD>-130</TD><TD>-3.54</TD></TR><TR><TD>Lancer LCR Footwear JJ Air White Navy - 221068</TD><TD>211</TD><TD>383</TD><TD>206</TD><TD>400</TD><TD>141</TD><TD>0</TD><TD>7</TD><TD>1341</TD><TD>1334</TD><TD>19057.14</TD></TR><TR><TD>Columbus Shoes - Green - 202033</TD><TD>65</TD><TD>190</TD><TD>134</TD><TD>128</TD><TD>532</TD><TD>640</TD><TD>2068</TD><TD>1689</TD><TD>-379</TD><TD>-18.33</TD></TR><TR><TD>Columbus Race2 White Blue Sports Shoe - 217145</TD><TD>94</TD><TD>87</TD><TD>32</TD><TD>80</TD><TD>108</TD><TD>132</TD><TD>0</TD><TD>533</TD><TD>533</TD><TD>100.00</TD></TR><TR><TD>Columbus Footwear Tab105 White Royal Blue - 215963</TD><TD>1</TD><TD>4</TD><TD>0</TD><TD>1</TD><TD>0</TD><TD>10</TD><TD>27</TD><TD>16</TD><TD>-11</TD><TD>-40.74</TD></TR><TR><TD>Stylish Biker Shoe - 198909</TD><TD>3</TD><TD>89</TD><TD>53</TD><TD>20</TD><TD>105</TD><TD>0</TD><TD>272</TD><TD>270</TD><TD>-2</TD><TD>-0.74</TD></TR><TR><TD>Rocio Sports shoe Blue White - 198456</TD><TD>10</TD><TD>2</TD><TD>164</TD><TD>203</TD><TD>107</TD><TD>0</TD><TD>487</TD><TD>486</TD><TD>-1</TD><TD>-0.21</TD></TR><TR><TD>Rocio Sports Shoe  White Blue - 198457</TD><TD>0</TD><TD>0</TD><TD>9</TD><TD>66</TD><TD>9</TD><TD>0</TD><TD>108</TD><TD>84</TD><TD>-24</TD><TD>-22.22</TD></TR><TR><TD>Rocio Formal Shoes  - 38087</TD><TD>67</TD><TD>183</TD><TD>206</TD><TD>98</TD><TD>54</TD><TD>0</TD><TD>656</TD><TD>608</TD><TD>-48</TD><TD>-7.32</TD></TR><TR><TD>MARCO FERRO TAN SHOES - 60894</TD><TD>334</TD><TD>6</TD><TD>6</TD><TD>164</TD><TD>268</TD><TD>0</TD><TD>784</TD><TD>778</TD><TD>-6</TD><TD>-0.77</TD></TR><TR><TD>Marco Ferro Olive Shoes - Olive - 195566</TD><TD>256</TD><TD>56</TD><TD>856</TD><TD>999</TD><TD>591</TD><TD>0</TD><TD>2814</TD><TD>2758</TD><TD>-56</TD><TD>-1.99</TD></TR><TR><TD>Marco ferro Boot - Tan - 197672</TD><TD>136</TD><TD>13</TD><TD>5</TD><TD>313</TD><TD>100</TD><TD>0</TD><TD>594</TD><TD>567</TD><TD>-27</TD><TD>-4.55</TD></TR><TR><TD>Columbus Shoes - 214619</TD><TD>7</TD><TD>90</TD><TD>82</TD><TD>30</TD><TD>87</TD><TD>0</TD><TD>283</TD><TD>296</TD><TD>13</TD><TD>4.59</TD></TR><TR><TD>Columbus Shoes - Blue - 202034</TD><TD>18</TD><TD>71</TD><TD>57</TD><TD>42</TD><TD>69</TD><TD>14</TD><TD>307</TD><TD>271</TD><TD>-36</TD><TD>-11.73</TD></TR><TR><TD>Columbus Shoes - Red - 202035</TD><TD>27</TD><TD>50</TD><TD>68</TD><TD>45</TD><TD>26</TD><TD>6</TD><TD>229</TD><TD>222</TD><TD>-7</TD><TD>-3.06</TD></TR><TR><TD>Columbus Shoes - Tab - White/Red/Black - 214618</TD><TD>33</TD><TD>145</TD><TD>86</TD><TD>73</TD><TD>88</TD><TD>0</TD><TD>420</TD><TD>425</TD><TD>5</TD><TD>1.19</TD></TR><TR><TD>Columbus Shoes - Tab White Blue - 214617</TD><TD>54</TD><TD>156</TD><TD>43</TD><TD>47</TD><TD>70</TD><TD>0</TD><TD>372</TD><TD>370</TD><TD>-2</TD><TD>-0.54</TD></TR><TR><TD>Lotto Magic Shoes - 129726</TD><TD>0</TD><TD>4</TD><TD>0</TD><TD>8</TD><TD>1</TD><TD>0</TD><TD>13</TD><TD>13</TD><TD>0</TD><TD>0.00</TD></TR><TR><TD>Grand Total</TD><TD>1369</TD><TD>2203</TD><TD>2899</TD><TD>4969</TD><TD>3229</TD><TD>802</TD><TD>14374</TD><TD>15471</TD><TD>1097</TD><TD>7.63</TD></TR></TABLE>
<br><br>Small Shoes Bulk Inventory Report <br><br>
<TABLE BORDER=1><TR><TH>Shoes</TH><TH>size 4</TH><TH>size 5</TH><TH>size 6</TH><TH>size 7</TH><TH>LastDay_Total</TH><TH>Today_Total</TH><TH>Quantity Change</TH><TH>% Change</TH></TR><TR><TD>Lotto Diva Women White Pink - 203979</TD><TD>581</TD><TD>1214</TD><TD>1067</TD><TD>475</TD><TD>3341</TD><TD>3337</TD><TD>-4</TD><TD>-0.12</TD></TR><TR><TD>Grand Total</TD><TD>581</TD><TD>1214</TD><TD>1067</TD><TD>475</TD><TD>3341</TD><TD>3337</TD><TD>-4</TD><TD>-0.12</TD></TR></TABLE>
<br><br>Apparel Bulk Inventory Report<br><br>
<TABLE BORDER=1><TR><TH>Apparel</TH><TH>Size - S</TH><TH>Size - M</TH><TH>Size - L</TH><TH>Size - XL</TH><TH>Size - XXL</TH><TH>LastDay_Total</TH><TH>Today_Total</TH><TH>Quantity Change</TH><TH>% Change</TH></TR><TR><TD>Lotto Tracksuit - 199346</TD><TD>895</TD><TD>2765</TD><TD>2763</TD><TD>1646</TD><TD>778</TD><TD>8849</TD><TD>8847</TD><TD>-2</TD><TD>-0.02</TD></TR><TR><TD>Rocio Black Bomber Jacket - 201734</TD><TD>0</TD><TD>77</TD><TD>268</TD><TD>216</TD><TD>0</TD><TD>562</TD><TD>561</TD><TD>-1</TD><TD>-0.18</TD></TR><TR><TD>Rocio Black Full Sleeve Jacket with Fur Lining - 202674</TD><TD>0</TD><TD>32</TD><TD>3</TD><TD>30</TD><TD>0</TD><TD>65</TD><TD>65</TD><TD>0</TD><TD>0.00</TD></TR><TR><TD>Rocio Blue Bomber Jacket - 201735</TD><TD>0</TD><TD>117</TD><TD>324</TD><TD>313</TD><TD>0</TD><TD>754</TD><TD>754</TD><TD>0</TD><TD>0.00</TD></TR><TR><TD>Rocio Mens Black Tracksuit with Blue Piping - 199529</TD><TD>426</TD><TD>1301</TD><TD>1300</TD><TD>683</TD><TD>350</TD><TD>4060</TD><TD>4060</TD><TD>0</TD><TD>0.00</TD></TR><TR><TD>Rocio Mens Black Tracksuit with Red Piping - 199530</TD><TD>458</TD><TD>1226</TD><TD>1330</TD><TD>739</TD><TD>332</TD><TD>4085</TD><TD>4085</TD><TD>0</TD><TD>0.00</TD></TR><TR><TD>Grand Total</TD><TD>1779</TD><TD>5518</TD><TD>5988</TD><TD>3627</TD><TD>1460</TD><TD>18375</TD><TD>18372</TD><TD>-3</TD><TD>-0.02</TD></TR></TABLE>

将 TD 替换为 TH 后的 myoutput.txt 内容:

<br><br>Shoes Bulk Inventory Report <br><br>
<TABLE BORDER=1><TR><TH>Shoes</TH><TH>size 6</TH><TH>size 7</TH><TH>size 8</TH><TH>size 9</TH><TH>size 10</TH><TH>size 11</TH><TH>LastDay_Total</TH><TH>Today_Total</TH><TH>Quantity Change</TH><TH>% Change</TH></TR><TR><TD>Marco ferro Boot - Black - 198747</TD><TD>0</TD><TD>40</TD><TD>143</TD><TD>301</TD><TD>23</TD><TD>0</TD><TD>556</TD><TD>507</TD><TD>-49</TD><TD>-8.81</TD></TR><TR><TD>Lotto Marathon Shoes White Navy - 196553</TD><TD>2</TD><TD>410</TD><TD>105</TD><TD>26</TD><TD>152</TD><TD>0</TD><TD>705</TD><TD>695</TD><TD>-10</TD><TD>-1.42</TD></TR><TR><TD>LOTTO MAGIC SHOES - Blue - 196552</TD><TD>51</TD><TD>224</TD><TD>644</TD><TD>1925</TD><TD>698</TD><TD>0</TD><TD>3672</TD><TD>3542</TD><TD>-130</TD><TD>-3.54</TD></TR><TR><TD>Lancer LCR Footwear JJ Air White Navy - 221068</TD><TD>211</TD><TD>383</TD><TD>206</TD><TD>400</TD><TD>141</TD><TD>0</TD><TD>7</TD><TD>1341</TD><TD>1334</TD><TD>19057.14</TD></TR><TR><TD>Columbus Shoes - Green - 202033</TD><TD>65</TD><TD>190</TD><TD>134</TD><TD>128</TD><TD>532</TD><TD>640</TD><TD>2068</TD><TD>1689</TD><TD>-379</TD><TD>-18.33</TD></TR><TR><TD>Columbus Race2 White Blue Sports Shoe - 217145</TD><TD>94</TD><TD>87</TD><TD>32</TD><TD>80</TD><TD>108</TD><TD>132</TD><TD>0</TD><TD>533</TD><TD>533</TD><TD>100.00</TD></TR><TR><TD>Columbus Footwear Tab105 White Royal Blue - 215963</TD><TD>1</TD><TD>4</TD><TD>0</TD><TD>1</TD><TD>0</TD><TD>10</TD><TD>27</TD><TD>16</TD><TD>-11</TD><TD>-40.74</TD></TR><TR><TD>Stylish Biker Shoe - 198909</TD><TD>3</TD><TD>89</TD><TD>53</TD><TD>20</TD><TD>105</TD><TD>0</TD><TD>272</TD><TD>270</TD><TD>-2</TD><TD>-0.74</TD></TR><TR><TD>Rocio Sports shoe Blue White - 198456</TD><TD>10</TD><TD>2</TD><TD>164</TD><TD>203</TD><TD>107</TD><TD>0</TD><TD>487</TD><TD>486</TD><TD>-1</TD><TD>-0.21</TD></TR><TR><TD>Rocio Sports Shoe  White Blue - 198457</TD><TD>0</TD><TD>0</TD><TD>9</TD><TD>66</TD><TD>9</TD><TD>0</TD><TD>108</TD><TD>84</TD><TD>-24</TD><TD>-22.22</TD></TR><TR><TD>Rocio Formal Shoes  - 38087</TD><TD>67</TD><TD>183</TD><TD>206</TD><TD>98</TD><TD>54</TD><TD>0</TD><TD>656</TD><TD>608</TD><TD>-48</TD><TD>-7.32</TD></TR><TR><TD>MARCO FERRO TAN SHOES - 60894</TD><TD>334</TD><TD>6</TD><TD>6</TD><TD>164</TD><TD>268</TD><TD>0</TD><TD>784</TD><TD>778</TD><TD>-6</TD><TD>-0.77</TD></TR><TR><TD>Marco Ferro Olive Shoes - Olive - 195566</TD><TD>256</TD><TD>56</TD><TD>856</TD><TD>999</TD><TD>591</TD><TD>0</TD><TD>2814</TD><TD>2758</TD><TD>-56</TD><TD>-1.99</TD></TR><TR><TD>Marco ferro Boot - Tan - 197672</TD><TD>136</TD><TD>13</TD><TD>5</TD><TD>313</TD><TD>100</TD><TD>0</TD><TD>594</TD><TD>567</TD><TD>-27</TD><TD>-4.55</TD></TR><TR><TD>Columbus Shoes - 214619</TD><TD>7</TD><TD>90</TD><TD>82</TD><TD>30</TD><TD>87</TD><TD>0</TD><TD>283</TD><TD>296</TD><TD>13</TD><TD>4.59</TD></TR><TR><TD>Columbus Shoes - Blue - 202034</TD><TD>18</TD><TD>71</TD><TD>57</TD><TD>42</TD><TD>69</TD><TD>14</TD><TD>307</TD><TD>271</TD><TD>-36</TD><TD>-11.73</TD></TR><TR><TD>Columbus Shoes - Red - 202035</TD><TD>27</TD><TD>50</TD><TD>68</TD><TD>45</TD><TD>26</TD><TD>6</TD><TD>229</TD><TD>222</TD><TD>-7</TD><TD>-3.06</TD></TR><TR><TD>Columbus Shoes - Tab - White/Red/Black - 214618</TD><TD>33</TD><TD>145</TD><TD>86</TD><TD>73</TD><TD>88</TD><TD>0</TD><TD>420</TD><TD>425</TD><TD>5</TD><TD>1.19</TD></TR><TR><TD>Columbus Shoes - Tab White Blue - 214617</TD><TD>54</TD><TD>156</TD><TD>43</TD><TD>47</TD><TD>70</TD><TD>0</TD><TD>372</TD><TD>370</TD><TD>-2</TD><TD>-0.54</TD></TR><TR><TD>Lotto Magic Shoes - 129726</TD><TD>0</TD><TD>4</TD><TD>0</TD><TD>8</TD><TD>1</TD><TD>0</TD><TD>13</TD><TD>13</TD><TD>0</TD><TD>0.00</TD></TR><TR><TH>Grand Total</TH><TH>1369</TH><TH>2203</TH><TH>2899</TH><TH>4969</TH><TH>3229</TH><TH>802</TH><TH>14374</TH><TH>15471</TH><TH>1097</TH><TH>7.63</TH></TR></TABLE>
<br><br>Small Shoes Bulk Inventory Report <br><br>
<TABLE BORDER=1><TR><TH>Shoes</TH><TH>size 4</TH><TH>size 5</TH><TH>size 6</TH><TH>size 7</TH><TH>LastDay_Total</TH><TH>Today_Total</TH><TH>Quantity Change</TH><TH>% Change</TH></TR><TR><TD>Lotto Diva Women White Pink - 203979</TD><TD>581</TD><TD>1214</TD><TD>1067</TD><TD>475</TD><TD>3341</TD><TD>3337</TD><TD>-4</TD><TD>-0.12</TD></TR><TR><TH>Grand Total</TH><TH>581</TH><TH>1214</TH><TH>1067</TH><TH>475</TH><TH>3341</TH><TH>3337</TH><TH>-4</TH><TH>-0.12</TH></TR></TABLE>
<br><br>Apparel Bulk Inventory Report<br><br>
<TABLE BORDER=1><TR><TH>Apparel</TH><TH>Size - S</TH><TH>Size - M</TH><TH>Size - L</TH><TH>Size - XL</TH><TH>Size - XXL</TH><TH>LastDay_Total</TH><TH>Today_Total</TH><TH>Quantity Change</TH><TH>% Change</TH></TR><TR><TD>Lotto Tracksuit - 199346</TD><TD>895</TD><TD>2765</TD><TD>2763</TD><TD>1646</TD><TD>778</TD><TD>8849</TD><TD>8847</TD><TD>-2</TD><TD>-0.02</TD></TR><TR><TD>Rocio Black Bomber Jacket - 201734</TD><TD>0</TD><TD>77</TD><TD>268</TD><TD>216</TD><TD>0</TD><TD>562</TD><TD>561</TD><TD>-1</TD><TD>-0.18</TD></TR><TR><TD>Rocio Black Full Sleeve Jacket with Fur Lining - 202674</TD><TD>0</TD><TD>32</TD><TD>3</TD><TD>30</TD><TD>0</TD><TD>65</TD><TD>65</TD><TD>0</TD><TD>0.00</TD></TR><TR><TD>Rocio Blue Bomber Jacket - 201735</TD><TD>0</TD><TD>117</TD><TD>324</TD><TD>313</TD><TD>0</TD><TD>754</TD><TD>754</TD><TD>0</TD><TD>0.00</TD></TR><TR><TD>Rocio Mens Black Tracksuit with Blue Piping - 199529</TD><TD>426</TD><TD>1301</TD><TD>1300</TD><TD>683</TD><TD>350</TD><TD>4060</TD><TD>4060</TD><TD>0</TD><TD>0.00</TD></TR><TR><TD>Rocio Mens Black Tracksuit with Red Piping - 199530</TD><TD>458</TD><TD>1226</TD><TD>1330</TD><TD>739</TD><TD>332</TD><TD>4085</TD><TD>4085</TD><TD>0</TD><TD>0.00</TD></TR><TR><TH>Grand Total</TH><TH>1779</TH><TH>5518</TH><TH>5988</TH><TH>3627</TH><TH>1460</TH><TH>18375</TH><TH>18372</TH><TH>-3</TH><TH>-0.02</TH></TR></TABLE>

相关内容

  • 没有找到相关文章

最新更新