12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- BEGIN{
- styles=0
- in_style=0
- rows=-1
- in_cell=0
- }
- {
- if(match($0,"^ *<Table")){
- rows=0
- print
- next
- }
- if(match($0,"^ *</Table")){
- rows=-1
- print
- next
- }
- if(match($0,"^ *<Row[ >]")){
- if(rows<4)rows++
- }
- # if(rows>-1){
- # if(rows<4)
- # gsub(" ss:StyleID=\"\\w+\""," ss:StyleID=\"s1\"",$0)
- # else
- # gsub(" ss:StyleID=\"\\w+\"","",$0)
- # }
- # if(match($0,"^ *<Style ")){
- # if(styles<3) styles++
- # }
- if(match($0,"^ *<Cell\\W.*</Cell>$")||match($0,"^ *<Cell\\W.*/>$")||match($0,"^ *<Cell/>$")){
- print
- next
- }
- if(match($0,"^ *<Cell(\\W|$)")){
- ORS=""
- in_cell=1
- print
- next
- }
- if(in_cell==1){
- gsub("^ +"," ",$0)
- }
- if(match($0,"</Cell>$")){
- in_cell=0
- }
- if(in_cell==1){
- ORS=""
- gsub("\r?\n","",$0)
- }else{
- ORS="\n"
- }
- if(match($0,"^ *<Style ")){
- in_style=1
- if(styles==0){
- styles++
- print
- next
- }
- else if(styles==1) {
- gsub("ss:ID=\"\\w+\"","ss:ID=\"s1\"",$0)
- styles++
- print $0
- next
- } else {
- if(styles<3) styles++
- in_style=1
- }
- }
- if(match($0,"^ *</Style>")){
- in_style=0
- if(styles>2 )next
- }
- if(in_style && styles>2 )next
- print $0
- }
|