How to use ColSpan method of html Package

Best K6 code snippet using html.ColSpan

html_handler.go

Source:html_handler.go Github

copy

Full Screen

1package handlers2import (3 "regexp"4 "strings"5 "github.com/orgs/mdyazilim/html-converter-new/models"6 "github.com/orgs/mdyazilim/html-converter-new/utils"7)8func GetParsedHtml(data string, fileName string, uniqueID string, _packageCreataDate string, _packageNumber string)[] models.ExcelDto {9 var _ListHtml[] models.ExcelDto10 _ListHtml = append(_ListHtml, * utils.GetDefaultColumns())11 html := utils.GetDataFromHtml(data, "table tr td table tr td table")12 parsedHtml := strings.Split(html, "<td class=\"BG0 S\" colspan=\"9\">")13 for _, masterRow := range parsedHtml {14 utils.WriteValue(masterRow)15 if strings.Contains(masterRow, "<td class=\"BG1 S\" colspan=\"16\">") {16 firstSplit := strings.Split(masterRow, "<td class=\"BG1 S\" colspan=\"16\">")17 for _,18 firstRow := range firstSplit {19 utils.WriteValue(firstRow)20 if strings.Contains(firstRow, "<td class=\"BG2 S\" colspan=\"15\">") {21 secondSplit := strings.Split(firstRow, "<td class=\"BG2 S\" colspan=\"15\">")22 for _,23 secondRow := range secondSplit {24 utils.WriteValue(secondRow)25 if strings.Contains(secondRow, "<td class=\"BG0 S\" colspan=\"16\">") {26 splitData2 := strings.Split(secondRow, "<td class=\"BG0 S\" colspan=\"16\">")27 for _,28 bg0Data := range splitData2 {29 utils.WriteValue(bg0Data)30 trSplitdata := strings.Split(bg0Data, "<tr>")31 for _, row := range trSplitdata {32 utils.WriteValue(row)33 _index := "0"34 if strings.Contains(row, "class=\"BG0") {35 _index = "3"36 } else if strings.Contains(row, "class=\"BG1") {37 _index = "4"38 } else if strings.Contains(row, "class=\"BG2") {39 _index = "2"40 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {41 _index = "3"42 }43 val := utils.ParseData(row, _index)44 if utils.FieldControl(val) {45 _ListHtml = append(_ListHtml, * val)46 }47 }48 }49 } else if strings.Contains(secondRow, "<td class=\"BG2 S\" colspan=\"16\">") {50 splitData := strings.Split(firstRow, "<td class=\"BG2 S\" colspan=\"16\">")51 for _,52 bg2Data := range splitData {53 utils.WriteValue(bg2Data)54 trSplitdata := strings.Split(bg2Data, "<tr>")55 for _, row := range trSplitdata {56 utils.WriteValue(row)57 _index := "0"58 if strings.Contains(row, "class=\"BG0") {59 _index = "3"60 } else if strings.Contains(row, "class=\"BG1") {61 _index = "1"62 } else if strings.Contains(row, "class=\"BG2") {63 _index = "2"64 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {65 _index = "3"66 }67 val := utils.ParseData(row, _index)68 if utils.FieldControl(val) {69 _ListHtml = append(_ListHtml, * val)70 }71 }72 }73 } else if strings.Contains(secondRow, "<td class=\"BG0 S\" colspan=\"14\">") {74 splitDataThird := strings.Split(secondRow, "<td class=\"BG0 S\" colspan=\"14\">")75 for _,76 thirdData := range splitDataThird {77 utils.WriteValue(thirdData)78 if strings.Contains(thirdData, "<td class=\"BG1 S\" colspan=\"16\">") {79 splitBg016 := strings.Split(thirdData, "<td class=\"BG1 S\" colspan=\"16\">")80 for _,81 bg2Data := range splitBg016 {82 utils.WriteValue(bg2Data)83 trSplitdata := strings.Split(bg2Data, "<tr>")84 for _, row := range trSplitdata {85 utils.WriteValue(row)86 _index := "0"87 if strings.Contains(row, "class=\"BG0") {88 _index = "3"89 } else if strings.Contains(row, "class=\"BG1") {90 _index = "4"91 } else if strings.Contains(row, "class=\"BG2") {92 _index = "5"93 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {94 _index = "3"95 }96 val := utils.ParseData(row, _index)97 if utils.FieldControl(val) {98 _ListHtml = append(_ListHtml, * val)99 }100 }101 }102 } else if strings.Contains(firstRow, "<td class=\"BG2 S\" colspan=\"9\">") {103 splitbgos15 := strings.Split(firstRow, "<td class=\"BG2 S\" colspan=\"9\">")104 for _,105 bgorow := range splitbgos15 {106 trSplitdata := strings.Split(bgorow, "<tr>")107 for _,108 row := range trSplitdata {109 utils.WriteValue(row)110 _index := "0"111 if strings.Contains(row, "class=\"BG0") {112 _index = "2"113 } else if strings.Contains(row, "class=\"BG1") {114 _index = "4"115 } else if strings.Contains(row, "class=\"BG2\">") {116 _index = "5"117 } else if strings.Contains(row, "class=\"BG2 S") {118 _index = "2"119 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {120 _index = "3"121 }122 val := utils.ParseData(row, _index)123 if utils.FieldControl(val) {124 _ListHtml = append(_ListHtml, * val)125 }126 }127 }128 } else {129 trSplitdata := strings.Split(thirdData, "<tr>")130 for _,131 row := range trSplitdata {132 utils.WriteValue(row)133 _index := "0"134 if strings.Contains(row, "class=\"BG0") {135 _index = "3"136 } else if strings.Contains(row, "class=\"BG1") {137 _index = "4"138 } else if strings.Contains(row, "class=\"BG2\">") {139 _index = "5"140 } else if strings.Contains(row, "class=\"BG2 S") {141 _index = "2"142 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {143 _index = "3"144 }145 val := utils.ParseData(row, _index)146 if utils.FieldControl(val) {147 _ListHtml = append(_ListHtml, * val)148 }149 }150 }151 }152 } else if (strings.Contains(secondRow, "<td class=\"BG0 S\" colspan=\"15\">")) {153 splitDataThird := strings.Split(secondRow, "<td class=\"BG0 S\" colspan=\"14\">")154 for _,155 thirdData := range splitDataThird {156 utils.WriteValue(thirdData)157 if strings.Contains(thirdData, "<td class=\"BG1 S\" colspan=\"16\">") {158 splitBg016 := strings.Split(thirdData, "<td class=\"BG1 S\" colspan=\"16\">")159 for _,160 bg2Data := range splitBg016 {161 utils.WriteValue(bg2Data)162 trSplitdata := strings.Split(bg2Data, "<tr>")163 for _, row := range trSplitdata {164 utils.WriteValue(row)165 _index := "0"166 if strings.Contains(row, "class=\"BG0") {167 _index = "3"168 } else if strings.Contains(row, "class=\"BG1") {169 _index = "3"170 } else if strings.Contains(row, "class=\"BG2") {171 _index = "5"172 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {173 _index = "3"174 }175 val := utils.ParseData(row, _index)176 if utils.FieldControl(val) {177 _ListHtml = append(_ListHtml, * val)178 }179 }180 }181 } else if strings.Contains(firstRow, "<td class=\"BG2 S\" colspan=\"9\">") {182 splitbgos15 := strings.Split(firstRow, "<td class=\"BG2 S\" colspan=\"9\">")183 for _,184 bgorow := range splitbgos15 {185 trSplitdata := strings.Split(bgorow, "<tr>")186 for _,187 row := range trSplitdata {188 utils.WriteValue(row)189 _index := "0"190 if strings.Contains(row, "class=\"BG0") {191 _index = "2"192 } else if strings.Contains(row, "class=\"BG1") {193 _index = "4"194 } else if strings.Contains(row, "class=\"BG2\">") {195 _index = "5"196 } else if strings.Contains(row, "class=\"BG2 S") {197 _index = "2"198 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {199 _index = "3"200 }201 val := utils.ParseData(row, _index)202 if utils.FieldControl(val) {203 _ListHtml = append(_ListHtml, * val)204 }205 }206 }207 } else {208 trSplitdata := strings.Split(thirdData, "<tr>")209 for _,210 row := range trSplitdata {211 utils.WriteValue(row)212 _index := "0"213 if strings.Contains(row, "class=\"BG0") {214 _index = "3"215 } else if strings.Contains(row, "class=\"BG1") {216 _index = "4"217 } else if strings.Contains(row, "class=\"BG2\">") {218 _index = "5"219 } else if strings.Contains(row, "class=\"BG2 S") {220 _index = "2"221 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {222 _index = "3"223 }224 val := utils.ParseData(row, _index)225 if utils.FieldControl(val) {226 _ListHtml = append(_ListHtml, * val)227 }228 }229 }230 }231 } else232 if strings.Contains(secondRow, "<td class=\"BG0 S\" colspan=\"15\">") {233 splitbgos15 := strings.Split(secondRow, "<td class=\"BG0 S\" colspan=\"15\">")234 for _,235 bgorow := range splitbgos15 {236 utils.WriteValue(bgorow)237 if strings.Contains(bgorow, "<td class=\"BG1 S\" colspan=\"16\">") {238 splitBg016 := strings.Split(bgorow, "<td class=\"BG1 S\" colspan=\"16\">")239 for _,240 bg2Data := range splitBg016 {241 utils.WriteValue(bg2Data)242 trSplitdata := strings.Split(bg2Data, "<tr>")243 for _, row := range trSplitdata {244 utils.WriteValue(row)245 _index := "0"246 if strings.Contains(row, "class=\"BG0") {247 _index = "3"248 } else if strings.Contains(row, "class=\"BG1") {249 _index = "4"250 } else if strings.Contains(row, "class=\"BG2") {251 _index = "5"252 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {253 _index = "3"254 }255 val := utils.ParseData(row, _index)256 if utils.FieldControl(val) {257 _ListHtml = append(_ListHtml, * val)258 }259 }260 }261 } else {262 trSplitdata := strings.Split(bgorow, "<tr>")263 for _,264 row := range trSplitdata {265 utils.WriteValue(row)266 _index := "0"267 if strings.Contains(row, "class=\"BG0") {268 _index = "3"269 } else if strings.Contains(row, "class=\"BG1") {270 _index = "4"271 } else if strings.Contains(row, "class=\"BG2\">") {272 _index = "5"273 } else if strings.Contains(row, "class=\"BG2 S") {274 _index = "2"275 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {276 _index = "3"277 }278 val := utils.ParseData(row, _index)279 if utils.FieldControl(val) {280 _ListHtml = append(_ListHtml, * val)281 }282 }283 }284 }285 } else {286 trSplitdata := strings.Split(secondRow, "<tr>")287 for _,288 row := range trSplitdata {289 utils.WriteValue(row)290 _index := "0"291 if strings.Contains(row, "class=\"BG0") {292 _index = "3"293 } else if strings.Contains(row, "class=\"BG1") {294 _index = "1"295 } else if strings.Contains(row, "class=\"BG2") {296 _index = "2"297 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {298 _index = "3"299 }300 val := utils.ParseData(row, _index)301 if utils.FieldControl(val) {302 _ListHtml = append(_ListHtml, * val)303 }304 }305 }306 }307 } else if strings.Contains(firstRow, "<td class=\"BG2 S\" colspan=\"16\">") {308 splitData := strings.Split(firstRow, "<td class=\"BG2 S\" colspan=\"16\">")309 for _,310 bg2Data := range splitData {311 utils.WriteValue(bg2Data)312 trSplitdata := strings.Split(bg2Data, "<tr>")313 for _, row := range trSplitdata {314 utils.WriteValue(row)315 _index := "0"316 if strings.Contains(row, "class=\"BG0") {317 _index = "3"318 } else if strings.Contains(row, "class=\"BG1") {319 _index = "1"320 } else if strings.Contains(row, "class=\"BG2") {321 _index = "2"322 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {323 _index = "3"324 }325 val := utils.ParseData(row, _index)326 if utils.FieldControl(val) {327 _ListHtml = append(_ListHtml, * val)328 }329 }330 }331 } else if strings.Contains(firstRow, "<td class=\"BG2 S\" colspan=\"14\">") {332 splitData := strings.Split(firstRow, "<td class=\"BG2 S\" colspan=\"14\">")333 for _,334 bg2Data := range splitData {335 utils.WriteValue(bg2Data)336 if strings.Contains(bg2Data, "<td class=\"BG0 S\" colspan=\"16\">") {337 split_span16 := strings.Split(bg2Data, "<td class=\"BG0 S\" colspan=\"16\">")338 for _,339 row_16 := range split_span16 {340 trSplitdata := strings.Split(row_16, "<tr>")341 for _,342 row := range trSplitdata {343 utils.WriteValue(row)344 _index := "0"345 if strings.Contains(row, "class=\"BG0") {346 _index = "3"347 } else if strings.Contains(row, "class=\"BG1") {348 _index = "4"349 } else if strings.Contains(row, "class=\"BG2") {350 _index = "2"351 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {352 _index = "3"353 }354 val := utils.ParseData(row, _index)355 if utils.FieldControl(val) {356 _ListHtml = append(_ListHtml, * val)357 }358 }359 }360 } else {361 trSplitdata := strings.Split(bg2Data, "<tr>")362 for _,363 row := range trSplitdata {364 utils.WriteValue(row)365 _index := "0"366 if strings.Contains(row, "class=\"BG0") {367 _index = "3"368 } else if strings.Contains(row, "class=\"BG1") {369 _index = "1"370 } else if strings.Contains(row, "class=\"BG2") {371 _index = "2"372 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {373 _index = "3"374 }375 val := utils.ParseData(row, _index)376 if utils.FieldControl(val) {377 _ListHtml = append(_ListHtml, * val)378 }379 }380 }381 }382 } else if strings.Contains(firstRow, "<td class=\"BG2 S\" colspan=\"13\">") {383 splitData := strings.Split(firstRow, "<td class=\"BG2 S\" colspan=\"13\">")384 for _,385 bg2Data := range splitData {386 utils.WriteValue(bg2Data)387 trSplitdata := strings.Split(bg2Data, "<tr>")388 for _, row := range trSplitdata {389 utils.WriteValue(row)390 _index := "0"391 if strings.Contains(row, "class=\"BG0") {392 _index = "2"393 } else if strings.Contains(row, "class=\"BG1") {394 _index = "1"395 } else if strings.Contains(row, "class=\"BG2") {396 _index = "2"397 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {398 _index = "3"399 }400 val := utils.ParseData(row, _index)401 if utils.FieldControl(val) {402 _ListHtml = append(_ListHtml, * val)403 }404 }405 }406 } else if strings.Contains(firstRow, "<td class=\"BG2 S\" colspan=\"17\">") {407 splitData := strings.Split(firstRow, "<td class=\"BG2 S\" colspan=\"17\">")408 for _,409 bg2Data := range splitData {410 utils.WriteValue(bg2Data)411 trSplitdata := strings.Split(bg2Data, "<tr>")412 for _, row := range trSplitdata {413 utils.WriteValue(row)414 _index := "0"415 if strings.Contains(row, "class=\"BG0") {416 _index = "2"417 } else if strings.Contains(row, "class=\"BG1") {418 _index = "1"419 } else if strings.Contains(row, "class=\"BG2") {420 _index = "2"421 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {422 _index = "3"423 }424 val := utils.ParseData(row, _index)425 if utils.FieldControl(val) {426 _ListHtml = append(_ListHtml, * val)427 }428 }429 }430 } else if strings.Contains(firstRow, "<td class=\"BG0 S\" colspan=\"15\">") {431 splitbgos15 := strings.Split(firstRow, "<td class=\"BG0 S\" colspan=\"15\">")432 for _,433 bgorow := range splitbgos15 {434 utils.WriteValue(bgorow)435 if strings.Contains(bgorow, "<td class=\"BG1 S\" colspan=\"16\">") {436 splitBg016 := strings.Split(bgorow, "<td class=\"BG1 S\" colspan=\"16\">")437 for _,438 bg2Data := range splitBg016 {439 utils.WriteValue(bg2Data)440 trSplitdata := strings.Split(bg2Data, "<tr>")441 for _, row := range trSplitdata {442 utils.WriteValue(row)443 _index := "0"444 if strings.Contains(row, "class=\"BG0") {445 _index = "3"446 } else if strings.Contains(row, "class=\"BG1") {447 _index = "4"448 } else if strings.Contains(row, "class=\"BG2") {449 _index = "5"450 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {451 _index = "3"452 }453 val := utils.ParseData(row, _index)454 if utils.FieldControl(val) {455 _ListHtml = append(_ListHtml, * val)456 }457 }458 }459 } else {460 trSplitdata := strings.Split(bgorow, "<tr>")461 for _,462 row := range trSplitdata {463 utils.WriteValue(row)464 _index := "0"465 if strings.Contains(row, "class=\"BG0") {466 _index = "3"467 } else if strings.Contains(row, "class=\"BG1") {468 _index = "4"469 } else if strings.Contains(row, "class=\"BG2\">") {470 _index = "5"471 } else if strings.Contains(row, "class=\"BG2 S") {472 _index = "2"473 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {474 _index = "3"475 }476 val := utils.ParseData(row, _index)477 if utils.FieldControl(val) {478 _ListHtml = append(_ListHtml, * val)479 }480 }481 }482 }483 } else if strings.Contains(firstRow, "<td class=\"BG2 S\" colspan=\"9\">") {484 splitbgos15 := strings.Split(firstRow, "<td class=\"BG2 S\" colspan=\"9\">")485 for _,486 bgorow := range splitbgos15 {487 trSplitdata := strings.Split(bgorow, "<tr>")488 for _,489 row := range trSplitdata {490 utils.WriteValue(row)491 _index := "0"492 if strings.Contains(row, "class=\"BG0") {493 _index = "2"494 } else if strings.Contains(row, "class=\"BG1") {495 _index = "4"496 } else if strings.Contains(row, "class=\"BG2\">") {497 _index = "5"498 } else if strings.Contains(row, "class=\"BG2 S") {499 _index = "2"500 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {501 _index = "3"502 }503 val := utils.ParseData(row, _index)504 if utils.FieldControl(val) {505 _ListHtml = append(_ListHtml, * val)506 }507 }508 }509 } else {510 trSplitdata := strings.Split(firstRow, "<tr>")511 for _,512 row := range trSplitdata {513 utils.WriteValue(row)514 _index := "0"515 if strings.Contains(row, "class=\"BG0") {516 _index = "master"517 } else if strings.Contains(row, "class=\"BG1") {518 _index = "1"519 } else if strings.Contains(row, "class=\"BG2") {520 _index = "2"521 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {522 _index = "3"523 }524 val := utils.ParseData(row, _index)525 if utils.FieldControl(val) {526 _ListHtml = append(_ListHtml, * val)527 }528 }529 }530 }531 } else if (strings.Contains(masterRow, "<td class=\"BG1 S\" colspan=\"15\">")) {532 split_colspan_16 := strings.Split(masterRow, "<td class=\"BG1 S\" colspan=\"15\">")533 for _,534 colspan_firstdata := range split_colspan_16 {535 utils.WriteValue(colspan_firstdata)536 if strings.Contains(colspan_firstdata, "<td class=\"BG2 S\" colspan=\"14\">") {537 utils.WriteValue(colspan_firstdata)538 split_colspan_14 := strings.Split(colspan_firstdata, "<td class=\"BG2 S\" colspan=\"14\">")539 for _,540 colspan_second := range split_colspan_14 {541 utils.WriteValue(colspan_second)542 if strings.Contains(colspan_second, "<td class=\"BG0 S\" colspan=\"16\">") {543 utils.WriteValue(colspan_second)544 splitData2 := strings.Split(colspan_second, "<td class=\"BG0 S\" colspan=\"16\">")545 utils.WriteValue("")546 for _,547 bg0Data := range splitData2 {548 utils.WriteValue(bg0Data)549 trSplitdata := strings.Split(bg0Data, "<tr>")550 for _, row := range trSplitdata {551 utils.WriteValue(row)552 _index := "0"553 if strings.Contains(row, "class=\"BG0") {554 _index = "3"555 } else if strings.Contains(row, "class=\"BG1") {556 _index = "4"557 } else if strings.Contains(row, "class=\"BG2\">") {558 _index = "5"559 } else if strings.Contains(row, "class=\"BG2 S") {560 _index = "2"561 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {562 _index = "3"563 }564 val := utils.ParseData(row, _index)565 if utils.FieldControl(val) {566 _ListHtml = append(_ListHtml, * val)567 }568 }569 }570 } else {571 trSplitdata := strings.Split(colspan_second, "<tr>")572 for _,573 row := range trSplitdata {574 utils.WriteValue(row)575 _index := "0"576 if strings.Contains(row, "class=\"BG0") {577 _index = "3"578 } else if strings.Contains(row, "class=\"BG1") {579 _index = "1"580 } else if strings.Contains(row, "class=\"BG2") {581 _index = "2"582 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {583 _index = "3"584 }585 val := utils.ParseData(row, _index)586 if utils.FieldControl(val) {587 _ListHtml = append(_ListHtml, * val)588 }589 }590 }591 }592 } else if strings.Contains(colspan_firstdata, "<td class=\"BG2 S\" colspan=\"16\">") {593 splitData := strings.Split(colspan_firstdata, "<td class=\"BG2 S\" colspan=\"16\">")594 for _,595 bg2Data := range splitData {596 utils.WriteValue(bg2Data)597 trSplitdata := strings.Split(bg2Data, "<tr>")598 for _, row := range trSplitdata {599 utils.WriteValue(row)600 _index := "0"601 if strings.Contains(row, "class=\"BG0") {602 _index = "3"603 } else if strings.Contains(row, "class=\"BG1") {604 _index = "1"605 } else if strings.Contains(row, "class=\"BG2") {606 _index = "2"607 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {608 _index = "3"609 }610 val := utils.ParseData(row, _index)611 if utils.FieldControl(val) {612 _ListHtml = append(_ListHtml, * val)613 }614 }615 }616 } else if strings.Contains(colspan_firstdata, "<td class=\"BG2 S\" colspan=\"13\">") {617 splitData := strings.Split(colspan_firstdata, "<td class=\"BG2 S\" colspan=\"13\">")618 for _,619 bg2Data := range splitData {620 utils.WriteValue(bg2Data)621 trSplitdata := strings.Split(bg2Data, "<tr>")622 for _, row := range trSplitdata {623 utils.WriteValue(row)624 _index := "0"625 if strings.Contains(row, "class=\"BG0") {626 _index = "3"627 } else if strings.Contains(row, "class=\"BG1") {628 _index = "1"629 } else if strings.Contains(row, "class=\"BG2") {630 _index = "2"631 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {632 _index = "3"633 }634 val := utils.ParseData(row, _index)635 if utils.FieldControl(val) {636 _ListHtml = append(_ListHtml, * val)637 }638 }639 }640 } else if strings.Contains(colspan_firstdata, "<td class=\"BG2 S\" colspan=\"17\">") {641 splitData := strings.Split(colspan_firstdata, "<td class=\"BG2 S\" colspan=\"17\">")642 for _,643 bg2Data := range splitData {644 utils.WriteValue(bg2Data)645 trSplitdata := strings.Split(bg2Data, "<tr>")646 for _, row := range trSplitdata {647 utils.WriteValue(row)648 _index := "0"649 if strings.Contains(row, "class=\"BG0") {650 _index = "3"651 } else if strings.Contains(row, "class=\"BG1") {652 _index = "1"653 } else if strings.Contains(row, "class=\"BG2") {654 _index = "2"655 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {656 _index = "3"657 }658 val := utils.ParseData(row, _index)659 if utils.FieldControl(val) {660 _ListHtml = append(_ListHtml, * val)661 }662 }663 }664 } else if strings.Contains(colspan_firstdata, "<td class=\"BG2 S\" colspan=\"15\">") {665 splitData := strings.Split(colspan_firstdata, "<td class=\"BG2 S\" colspan=\"15\">")666 for _,667 row15 := range splitData {668 utils.WriteValue(row15)669 if strings.Contains(row15, "<td class=\"BG2 S\" colspan=\"16\">") {670 splitgb216 := strings.Split(row15, "<td class=\"BG2 S\" colspan=\"16\">")671 for _,672 bg160row := range splitgb216 {673 if strings.Contains(bg160row, "<td class=\"BG0 S\" colspan=\"16\">") {674 for _, bg2Data := range strings.Split(bg160row, "<td class=\"BG0 S\" colspan=\"16\">") {675 utils.WriteValue(bg2Data)676 trSplitdata := strings.Split(bg2Data, "<tr>")677 for _, row := range trSplitdata {678 utils.WriteValue(row)679 _index := "0"680 if strings.Contains(row, "class=\"BG0") {681 _index = "3"682 } else if strings.Contains(row, "class=\"BG1") {683 _index = "4"684 } else if strings.Contains(row, "class=\"BG2") {685 _index = "2"686 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {687 _index = "3"688 }689 val := utils.ParseData(row, _index)690 if utils.FieldControl(val) {691 _ListHtml = append(_ListHtml, * val)692 }693 }694 }695 } else {696 trSplitdata := strings.Split(bg160row, "<tr>")697 for _, row := range trSplitdata {698 utils.WriteValue(row)699 _index := "0"700 if strings.Contains(row, "class=\"BG0") {701 _index = "3"702 } else if strings.Contains(row, "class=\"BG1") {703 _index = "1"704 } else if strings.Contains(row, "class=\"BG2") {705 _index = "2"706 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {707 _index = "3"708 }709 val := utils.ParseData(row, _index)710 if utils.FieldControl(val) {711 _ListHtml = append(_ListHtml, * val)712 }713 }714 }715 }716 } else if strings.Contains(row15, "<td class=\"BG0 S\" colspan=\"16\">") {717 split_data_bg016 := strings.Split(row15, "<td class=\"BG0 S\" colspan=\"16\">")718 for _,719 bg2Data := range split_data_bg016 {720 utils.WriteValue(bg2Data)721 trSplitdata := strings.Split(bg2Data, "<tr>")722 for _, row := range trSplitdata {723 utils.WriteValue(row)724 _index := "0"725 if strings.Contains(row, "class=\"BG0") {726 _index = "3"727 } else if strings.Contains(row, "class=\"BG1") {728 _index = "4"729 } else if strings.Contains(row, "class=\"BG2") {730 _index = "2"731 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {732 _index = "3"733 }734 val := utils.ParseData(row, _index)735 if utils.FieldControl(val) {736 _ListHtml = append(_ListHtml, * val)737 }738 }739 }740 } else {741 trSplitdata := strings.Split(row15, "<tr>")742 for _, row := range trSplitdata {743 utils.WriteValue(row)744 _index := "0"745 if strings.Contains(row, "class=\"BG0") {746 _index = "3"747 } else if strings.Contains(row, "class=\"BG1") {748 _index = "1"749 } else if strings.Contains(row, "class=\"BG2") {750 _index = "2"751 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {752 _index = "3"753 }754 val := utils.ParseData(row, _index)755 if utils.FieldControl(val) {756 _ListHtml = append(_ListHtml, * val)757 }758 }759 }760 }761 } else {762 trSplitdata := strings.Split(colspan_firstdata, "<tr>")763 for _,764 row := range trSplitdata {765 utils.WriteValue(row)766 _index := "0"767 if strings.Contains(row, "class=\"BG0") {768 _index = "master"769 } else if strings.Contains(row, "class=\"BG1") {770 _index = "1"771 } else if strings.Contains(row, "class=\"BG2") {772 _index = "2"773 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {774 _index = "3"775 }776 val := utils.ParseData(row, _index)777 if utils.FieldControl(val) {778 _ListHtml = append(_ListHtml, * val)779 }780 }781 }782 }783 } else784 if (strings.Contains(masterRow, "<td class=\"BG1 S\" colspan=\"17\">")) {785 split_colspan_17 := strings.Split(masterRow, "<td class=\"BG1 S\" colspan=\"17\">")786 for _,787 colspan_firstdata := range split_colspan_17 {788 utils.WriteValue(colspan_firstdata)789 if strings.Contains(colspan_firstdata, "<td class=\"BG2 S\" colspan=\"14\">") {790 utils.WriteValue(colspan_firstdata)791 split_colspan_14 := strings.Split(colspan_firstdata, "<td class=\"BG2 S\" colspan=\"14\">")792 for _,793 colspan_second := range split_colspan_14 {794 utils.WriteValue(colspan_second)795 if strings.Contains(colspan_second, "<td class=\"BG0 S\" colspan=\"16\">") {796 utils.WriteValue(colspan_second)797 splitData2 := strings.Split(colspan_second, "<td class=\"BG0 S\" colspan=\"16\">")798 utils.WriteValue("")799 for _,800 bg0Data := range splitData2 {801 utils.WriteValue(bg0Data)802 trSplitdata := strings.Split(bg0Data, "<tr>")803 for _, row := range trSplitdata {804 utils.WriteValue(row)805 _index := "0"806 if strings.Contains(row, "class=\"BG0") {807 _index = "3"808 } else if strings.Contains(row, "class=\"BG1") {809 _index = "4"810 } else if strings.Contains(row, "class=\"BG2\">") {811 _index = "2"812 } else if strings.Contains(row, "class=\"BG2 S") {813 _index = "2"814 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {815 _index = "3"816 }817 val := utils.ParseData(row, _index)818 if utils.FieldControl(val) {819 _ListHtml = append(_ListHtml, * val)820 }821 }822 }823 } else if (strings.Contains(colspan_second, "<td class=\"BG2 S\" colspan=\"16\">")) {824 trSplitdata := strings.Split(colspan_second, "<tr>")825 for _,826 row := range trSplitdata {827 utils.WriteValue(row)828 _index := "0"829 if strings.Contains(row, "class=\"BG0") {830 _index = "3"831 } else if strings.Contains(row, "class=\"BG1") {832 _index = "4"833 } else if strings.Contains(row, "class=\"BG2\">") {834 _index = "2"835 } else if strings.Contains(row, "class=\"BG2 S") {836 _index = "2"837 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {838 _index = "3"839 }840 val := utils.ParseData(row, _index)841 if utils.FieldControl(val) {842 _ListHtml = append(_ListHtml, * val)843 }844 }845 } else {846 trSplitdata := strings.Split(colspan_second, "<tr>")847 for _,848 row := range trSplitdata {849 utils.WriteValue(row)850 _index := "0"851 if strings.Contains(row, "class=\"BG0") {852 _index = "3"853 } else if strings.Contains(row, "class=\"BG1") {854 _index = "1"855 } else if strings.Contains(row, "class=\"BG2") {856 _index = "2"857 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {858 _index = "3"859 }860 val := utils.ParseData(row, _index)861 if utils.FieldControl(val) {862 _ListHtml = append(_ListHtml, * val)863 }864 }865 }866 }867 } else if strings.Contains(colspan_firstdata, "<td class=\"BG2 S\" colspan=\"16\">") {868 splitData := strings.Split(colspan_firstdata, "<td class=\"BG2 S\" colspan=\"16\">")869 for _,870 bg2Data := range splitData {871 utils.WriteValue(bg2Data)872 trSplitdata := strings.Split(bg2Data, "<tr>")873 for _, row := range trSplitdata {874 utils.WriteValue(row)875 _index := "0"876 if strings.Contains(row, "class=\"BG0") {877 _index = "3"878 } else if strings.Contains(row, "class=\"BG1") {879 _index = "1"880 } else if strings.Contains(row, "class=\"BG2") {881 _index = "2"882 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {883 _index = "3"884 }885 val := utils.ParseData(row, _index)886 if utils.FieldControl(val) {887 _ListHtml = append(_ListHtml, * val)888 }889 }890 }891 } else if (strings.Contains(colspan_firstdata, "<td class=\"BG2 S\" colspan=\"17\">")) {892 splitData := strings.Split(colspan_firstdata, "<td class=\"BG2 S\" colspan=\"17\">")893 for _,894 bg2Data := range splitData {895 utils.WriteValue(bg2Data)896 trSplitdata := strings.Split(bg2Data, "<tr>")897 for _, row := range trSplitdata {898 utils.WriteValue(row)899 _index := "0"900 if strings.Contains(row, "class=\"BG0") {901 _index = "3"902 } else if strings.Contains(row, "class=\"BG1") {903 _index = "1"904 } else if strings.Contains(row, "class=\"BG2") {905 _index = "2"906 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {907 _index = "3"908 }909 val := utils.ParseData(row, _index)910 if utils.FieldControl(val) {911 _ListHtml = append(_ListHtml, * val)912 }913 }914 }915 } else916 if (strings.Contains(colspan_firstdata, "<td class=\"BG2 S\" colspan=\"15\">")) {917 utils.WriteValue(colspan_firstdata)918 if strings.Contains(colspan_firstdata, "<td class=\"BG0 S\" colspan=\"15\">") {919 utils.WriteValue(colspan_firstdata)920 splitData2 := strings.Split(colspan_firstdata, "<td class=\"BG0 S\" colspan=\"16\">")921 utils.WriteValue("")922 for _,923 bg0Data := range splitData2 {924 utils.WriteValue(bg0Data)925 trSplitdata := strings.Split(bg0Data, "<tr>")926 for _, row := range trSplitdata {927 utils.WriteValue(row)928 _index := "0"929 if strings.Contains(row, "class=\"BG0") {930 _index = "3"931 } else if strings.Contains(row, "class=\"BG1") {932 _index = "4"933 } else if strings.Contains(row, "class=\"BG2\">") {934 _index = "2"935 } else if strings.Contains(row, "class=\"BG2 S") {936 _index = "2"937 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {938 _index = "3"939 }940 val := utils.ParseData(row, _index)941 if utils.FieldControl(val) {942 _ListHtml = append(_ListHtml, * val)943 }944 }945 }946 }947 } else if (strings.Contains(colspan_firstdata, "<td class=\"BG2 S\" colspan=\"13\">")) {948 splitcol13 := strings.Split(colspan_firstdata, "<td class=\"BG2 S\" colspan=\"13\">")949 for _,950 row := range splitcol13 {951 utils.WriteValue(row)952 _index := "0"953 if strings.Contains(row, "class=\"BG0") {954 _index = "3"955 } else if strings.Contains(row, "class=\"BG1") {956 _index = "4"957 } else if strings.Contains(row, "class=\"BG2\">") {958 _index = "2"959 } else if strings.Contains(row, "class=\"BG2 S") {960 _index = "2"961 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {962 _index = "3"963 }964 val := utils.ParseData(row, _index)965 if utils.FieldControl(val) {966 _ListHtml = append(_ListHtml, * val)967 }968 }969 } else {970 trSplitdata := strings.Split(colspan_firstdata, "<tr>")971 for _,972 row := range trSplitdata {973 utils.WriteValue(row)974 _index := "0"975 if strings.Contains(row, "class=\"BG0") {976 _index = "master"977 } else if strings.Contains(row, "class=\"BG1") {978 _index = "1"979 } else if strings.Contains(row, "class=\"BG2") {980 _index = "2"981 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {982 _index = "3"983 }984 val := utils.ParseData(row, _index)985 if utils.FieldControl(val) {986 _ListHtml = append(_ListHtml, * val)987 }988 }989 }990 }991 } else if (strings.Contains(masterRow, "<td class=\"BG1 S\" colspan=\"18\">")) {992 split_colspan_17 := strings.Split(masterRow, "<td class=\"BG1 S\" colspan=\"18\">")993 for _,994 colspan_firstdata := range split_colspan_17 {995 utils.WriteValue(colspan_firstdata)996 if strings.Contains(colspan_firstdata, "<td class=\"BG2 S\" colspan=\"14\">") {997 utils.WriteValue(colspan_firstdata)998 split_colspan_14 := strings.Split(colspan_firstdata, "<td class=\"BG2 S\" colspan=\"14\">")999 for _,1000 colspan_second := range split_colspan_14 {1001 utils.WriteValue(colspan_second)1002 if strings.Contains(colspan_second, "<td class=\"BG0 S\" colspan=\"16\">") {1003 utils.WriteValue(colspan_second)1004 splitData2 := strings.Split(colspan_second, "<td class=\"BG0 S\" colspan=\"16\">")1005 utils.WriteValue("")1006 for _,1007 bg0Data := range splitData2 {1008 utils.WriteValue(bg0Data)1009 trSplitdata := strings.Split(bg0Data, "<tr>")1010 for _, row := range trSplitdata {1011 utils.WriteValue(row)1012 _index := "0"1013 if strings.Contains(row, "class=\"BG0") {1014 _index = "3"1015 } else if strings.Contains(row, "class=\"BG1") {1016 _index = "4"1017 } else if strings.Contains(row, "class=\"BG2\">") {1018 _index = "2"1019 } else if strings.Contains(row, "class=\"BG2 S") {1020 _index = "2"1021 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {1022 _index = "3"1023 }1024 val := utils.ParseData(row, _index)1025 if utils.FieldControl(val) {1026 _ListHtml = append(_ListHtml, * val)1027 }1028 }1029 }1030 } else if (strings.Contains(colspan_second, "<td class=\"BG2 S\" colspan=\"16\">")) {1031 trSplitdata := strings.Split(colspan_second, "<tr>")1032 for _,1033 row := range trSplitdata {1034 utils.WriteValue(row)1035 _index := "0"1036 if strings.Contains(row, "class=\"BG0") {1037 _index = "3"1038 } else if strings.Contains(row, "class=\"BG1") {1039 _index = "4"1040 } else if strings.Contains(row, "class=\"BG2\">") {1041 _index = "2"1042 } else if strings.Contains(row, "class=\"BG2 S") {1043 _index = "2"1044 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {1045 _index = "3"1046 }1047 val := utils.ParseData(row, _index)1048 if utils.FieldControl(val) {1049 _ListHtml = append(_ListHtml, * val)1050 }1051 }1052 } else {1053 trSplitdata := strings.Split(colspan_second, "<tr>")1054 for _,1055 row := range trSplitdata {1056 utils.WriteValue(row)1057 _index := "0"1058 if strings.Contains(row, "class=\"BG0") {1059 _index = "3"1060 } else if strings.Contains(row, "class=\"BG1") {1061 _index = "1"1062 } else if strings.Contains(row, "class=\"BG2") {1063 _index = "2"1064 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {1065 _index = "3"1066 }1067 val := utils.ParseData(row, _index)1068 if utils.FieldControl(val) {1069 _ListHtml = append(_ListHtml, * val)1070 }1071 }1072 }1073 }1074 } else if strings.Contains(colspan_firstdata, "<td class=\"BG2 S\" colspan=\"16\">") {1075 splitData := strings.Split(colspan_firstdata, "<td class=\"BG2 S\" colspan=\"16\">")1076 for _,1077 bg2Data := range splitData {1078 utils.WriteValue(bg2Data)1079 trSplitdata := strings.Split(bg2Data, "<tr>")1080 for _, row := range trSplitdata {1081 utils.WriteValue(row)1082 _index := "0"1083 if strings.Contains(row, "class=\"BG0") {1084 _index = "3"1085 } else if strings.Contains(row, "class=\"BG1") {1086 _index = "1"1087 } else if strings.Contains(row, "class=\"BG2") {1088 _index = "2"1089 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {1090 _index = "3"1091 }1092 val := utils.ParseData(row, _index)1093 if utils.FieldControl(val) {1094 _ListHtml = append(_ListHtml, * val)1095 }1096 }1097 }1098 } else if (strings.Contains(colspan_firstdata, "<td class=\"BG2 S\" colspan=\"17\">")) {1099 splitData := strings.Split(colspan_firstdata, "<td class=\"BG2 S\" colspan=\"17\">")1100 for _,1101 bg2Data := range splitData {1102 utils.WriteValue(bg2Data)1103 trSplitdata := strings.Split(bg2Data, "<tr>")1104 for _, row := range trSplitdata {1105 utils.WriteValue(row)1106 _index := "0"1107 if strings.Contains(row, "class=\"BG0") {1108 _index = "3"1109 } else if strings.Contains(row, "class=\"BG1") {1110 _index = "1"1111 } else if strings.Contains(row, "class=\"BG2") {1112 _index = "2"1113 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {1114 _index = "3"1115 }1116 val := utils.ParseData(row, _index)1117 if utils.FieldControl(val) {1118 _ListHtml = append(_ListHtml, * val)1119 }1120 }1121 }1122 } else {1123 trSplitdata := strings.Split(colspan_firstdata, "<tr>")1124 for _,1125 row := range trSplitdata {1126 utils.WriteValue(row)1127 _index := "0"1128 if strings.Contains(row, "class=\"BG0") {1129 _index = "master"1130 } else if strings.Contains(row, "class=\"BG1") {1131 _index = "1"1132 } else if strings.Contains(row, "class=\"BG2") {1133 _index = "2"1134 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {1135 _index = "3"1136 }1137 val := utils.ParseData(row, _index)1138 if utils.FieldControl(val) {1139 _ListHtml = append(_ListHtml, * val)1140 }1141 }1142 }1143 }1144 } else if strings.Contains(masterRow, "<td class=\"BG1 S\" colspan=\"14\">") {1145 firstSplit := strings.Split(masterRow, "<td class=\"BG1 S\" colspan=\"14\">")1146 for _,1147 firstRow := range firstSplit {1148 utils.WriteValue(firstRow)1149 if strings.Contains(firstRow, "<td class=\"BG2 S\" colspan=\"15\">") {1150 secondSplit := strings.Split(firstRow, "<td class=\"BG2 S\" colspan=\"15\">")1151 for _,1152 secondRow := range secondSplit {1153 utils.WriteValue(secondRow)1154 if strings.Contains(secondRow, "<td class=\"BG0 S\" colspan=\"16\">") {1155 splitData2 := strings.Split(secondRow, "<td class=\"BG0 S\" colspan=\"16\">")1156 for _,1157 bg0Data := range splitData2 {1158 utils.WriteValue(bg0Data)1159 trSplitdata := strings.Split(bg0Data, "<tr>")1160 for _, row := range trSplitdata {1161 utils.WriteValue(row)1162 _index := "0"1163 if strings.Contains(row, "class=\"BG0") {1164 _index = "3"1165 } else if strings.Contains(row, "class=\"BG1") {1166 _index = "4"1167 } else if strings.Contains(row, "class=\"BG2") {1168 _index = "2"1169 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {1170 _index = "3"1171 }1172 val := utils.ParseData(row, _index)1173 if utils.FieldControl(val) {1174 _ListHtml = append(_ListHtml, * val)1175 }1176 }1177 }1178 } else if strings.Contains(secondRow, "<td class=\"BG2 S\" colspan=\"16\">") {1179 splitData := strings.Split(firstRow, "<td class=\"BG2 S\" colspan=\"16\">")1180 for _,1181 bg2Data := range splitData {1182 utils.WriteValue(bg2Data)1183 trSplitdata := strings.Split(bg2Data, "<tr>")1184 for _, row := range trSplitdata {1185 utils.WriteValue(row)1186 _index := "0"1187 if strings.Contains(row, "class=\"BG0") {1188 _index = "3"1189 } else if strings.Contains(row, "class=\"BG1") {1190 _index = "1"1191 } else if strings.Contains(row, "class=\"BG2") {1192 _index = "2"1193 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {1194 _index = "3"1195 }1196 val := utils.ParseData(row, _index)1197 if utils.FieldControl(val) {1198 _ListHtml = append(_ListHtml, * val)1199 }1200 }1201 }1202 } else if strings.Contains(secondRow, "<td class=\"BG0 S\" colspan=\"14\">") {1203 splitDataThird := strings.Split(secondRow, "<td class=\"BG0 S\" colspan=\"14\">")1204 for _,1205 thirdData := range splitDataThird {1206 utils.WriteValue(thirdData)1207 if strings.Contains(thirdData, "<td class=\"BG1 S\" colspan=\"16\">") {1208 splitBg016 := strings.Split(thirdData, "<td class=\"BG1 S\" colspan=\"16\">")1209 for _,1210 bg2Data := range splitBg016 {1211 utils.WriteValue(bg2Data)1212 trSplitdata := strings.Split(bg2Data, "<tr>")1213 for _, row := range trSplitdata {1214 utils.WriteValue(row)1215 _index := "0"1216 if strings.Contains(row, "class=\"BG0") {1217 _index = "3"1218 } else if strings.Contains(row, "class=\"BG1") {1219 _index = "4"1220 } else if strings.Contains(row, "class=\"BG2") {1221 _index = "5"1222 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {1223 _index = "3"1224 }1225 val := utils.ParseData(row, _index)1226 if utils.FieldControl(val) {1227 _ListHtml = append(_ListHtml, * val)1228 }1229 }1230 }1231 } else if strings.Contains(firstRow, "<td class=\"BG2 S\" colspan=\"9\">") {1232 splitbgos15 := strings.Split(firstRow, "<td class=\"BG2 S\" colspan=\"9\">")1233 for _,1234 bgorow := range splitbgos15 {1235 trSplitdata := strings.Split(bgorow, "<tr>")1236 for _,1237 row := range trSplitdata {1238 utils.WriteValue(row)1239 _index := "0"1240 if strings.Contains(row, "class=\"BG0") {1241 _index = "2"1242 } else if strings.Contains(row, "class=\"BG1") {1243 _index = "4"1244 } else if strings.Contains(row, "class=\"BG2\">") {1245 _index = "5"1246 } else if strings.Contains(row, "class=\"BG2 S") {1247 _index = "2"1248 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {1249 _index = "3"1250 }1251 val := utils.ParseData(row, _index)1252 if utils.FieldControl(val) {1253 _ListHtml = append(_ListHtml, * val)1254 }1255 }1256 }1257 } else {1258 trSplitdata := strings.Split(thirdData, "<tr>")1259 for _,1260 row := range trSplitdata {1261 utils.WriteValue(row)1262 _index := "0"1263 if strings.Contains(row, "class=\"BG0") {1264 _index = "3"1265 } else if strings.Contains(row, "class=\"BG1") {1266 _index = "4"1267 } else if strings.Contains(row, "class=\"BG2\">") {1268 _index = "5"1269 } else if strings.Contains(row, "class=\"BG2 S") {1270 _index = "2"1271 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {1272 _index = "3"1273 }1274 val := utils.ParseData(row, _index)1275 if utils.FieldControl(val) {1276 _ListHtml = append(_ListHtml, * val)1277 }1278 }1279 }1280 }1281 } else if (strings.Contains(secondRow, "<td class=\"BG0 S\" colspan=\"15\">")) {1282 splitDataThird := strings.Split(secondRow, "<td class=\"BG0 S\" colspan=\"14\">")1283 for _,1284 thirdData := range splitDataThird {1285 utils.WriteValue(thirdData)1286 if strings.Contains(thirdData, "<td class=\"BG1 S\" colspan=\"16\">") {1287 splitBg016 := strings.Split(thirdData, "<td class=\"BG1 S\" colspan=\"16\">")1288 for _,1289 bg2Data := range splitBg016 {1290 utils.WriteValue(bg2Data)1291 trSplitdata := strings.Split(bg2Data, "<tr>")1292 for _, row := range trSplitdata {1293 utils.WriteValue(row)1294 _index := "0"1295 if strings.Contains(row, "class=\"BG0") {1296 _index = "3"1297 } else if strings.Contains(row, "class=\"BG1") {1298 _index = "3"1299 } else if strings.Contains(row, "class=\"BG2") {1300 _index = "5"1301 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {1302 _index = "3"1303 }1304 val := utils.ParseData(row, _index)1305 if utils.FieldControl(val) {1306 _ListHtml = append(_ListHtml, * val)1307 }1308 }1309 }1310 } else if strings.Contains(firstRow, "<td class=\"BG2 S\" colspan=\"9\">") {1311 splitbgos15 := strings.Split(firstRow, "<td class=\"BG2 S\" colspan=\"9\">")1312 for _,1313 bgorow := range splitbgos15 {1314 trSplitdata := strings.Split(bgorow, "<tr>")1315 for _,1316 row := range trSplitdata {1317 utils.WriteValue(row)1318 _index := "0"1319 if strings.Contains(row, "class=\"BG0") {1320 _index = "2"1321 } else if strings.Contains(row, "class=\"BG1") {1322 _index = "4"1323 } else if strings.Contains(row, "class=\"BG2\">") {1324 _index = "5"1325 } else if strings.Contains(row, "class=\"BG2 S") {1326 _index = "2"1327 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {1328 _index = "3"1329 }1330 val := utils.ParseData(row, _index)1331 if utils.FieldControl(val) {1332 _ListHtml = append(_ListHtml, * val)1333 }1334 }1335 }1336 } else {1337 trSplitdata := strings.Split(thirdData, "<tr>")1338 for _,1339 row := range trSplitdata {1340 utils.WriteValue(row)1341 _index := "0"1342 if strings.Contains(row, "class=\"BG0") {1343 _index = "3"1344 } else if strings.Contains(row, "class=\"BG1") {1345 _index = "4"1346 } else if strings.Contains(row, "class=\"BG2\">") {1347 _index = "5"1348 } else if strings.Contains(row, "class=\"BG2 S") {1349 _index = "2"1350 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {1351 _index = "3"1352 }1353 val := utils.ParseData(row, _index)1354 if utils.FieldControl(val) {1355 _ListHtml = append(_ListHtml, * val)1356 }1357 }1358 }1359 }1360 } else1361 if strings.Contains(secondRow, "<td class=\"BG0 S\" colspan=\"15\">") {1362 splitbgos15 := strings.Split(secondRow, "<td class=\"BG0 S\" colspan=\"15\">")1363 for _,1364 bgorow := range splitbgos15 {1365 utils.WriteValue(bgorow)1366 if strings.Contains(bgorow, "<td class=\"BG1 S\" colspan=\"16\">") {1367 splitBg016 := strings.Split(bgorow, "<td class=\"BG1 S\" colspan=\"16\">")1368 for _,1369 bg2Data := range splitBg016 {1370 utils.WriteValue(bg2Data)1371 trSplitdata := strings.Split(bg2Data, "<tr>")1372 for _, row := range trSplitdata {1373 utils.WriteValue(row)1374 _index := "0"1375 if strings.Contains(row, "class=\"BG0") {1376 _index = "3"1377 } else if strings.Contains(row, "class=\"BG1") {1378 _index = "4"1379 } else if strings.Contains(row, "class=\"BG2") {1380 _index = "5"1381 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {1382 _index = "3"1383 }1384 val := utils.ParseData(row, _index)1385 if utils.FieldControl(val) {1386 _ListHtml = append(_ListHtml, * val)1387 }1388 }1389 }1390 } else {1391 trSplitdata := strings.Split(bgorow, "<tr>")1392 for _,1393 row := range trSplitdata {1394 utils.WriteValue(row)1395 _index := "0"1396 if strings.Contains(row, "class=\"BG0") {1397 _index = "3"1398 } else if strings.Contains(row, "class=\"BG1") {1399 _index = "4"1400 } else if strings.Contains(row, "class=\"BG2\">") {1401 _index = "5"1402 } else if strings.Contains(row, "class=\"BG2 S") {1403 _index = "2"1404 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {1405 _index = "3"1406 }1407 val := utils.ParseData(row, _index)1408 if utils.FieldControl(val) {1409 _ListHtml = append(_ListHtml, * val)1410 }1411 }1412 }1413 }1414 } else {1415 trSplitdata := strings.Split(secondRow, "<tr>")1416 for _,1417 row := range trSplitdata {1418 utils.WriteValue(row)1419 _index := "0"1420 if strings.Contains(row, "class=\"BG0") {1421 _index = "3"1422 } else if strings.Contains(row, "class=\"BG1") {1423 _index = "1"1424 } else if strings.Contains(row, "class=\"BG2") {1425 _index = "2"1426 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {1427 _index = "3"1428 }1429 val := utils.ParseData(row, _index)1430 if utils.FieldControl(val) {1431 _ListHtml = append(_ListHtml, * val)1432 }1433 }1434 }1435 }1436 } else if strings.Contains(firstRow, "<td class=\"BG2 S\" colspan=\"16\">") {1437 splitData := strings.Split(firstRow, "<td class=\"BG2 S\" colspan=\"16\">")1438 for _,1439 bg2Data := range splitData {1440 utils.WriteValue(bg2Data)1441 trSplitdata := strings.Split(bg2Data, "<tr>")1442 for _, row := range trSplitdata {1443 utils.WriteValue(row)1444 _index := "0"1445 if strings.Contains(row, "class=\"BG0") {1446 _index = "3"1447 } else if strings.Contains(row, "class=\"BG1") {1448 _index = "1"1449 } else if strings.Contains(row, "class=\"BG2") {1450 _index = "2"1451 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {1452 _index = "3"1453 }1454 val := utils.ParseData(row, _index)1455 if utils.FieldControl(val) {1456 _ListHtml = append(_ListHtml, * val)1457 }1458 }1459 }1460 } else if strings.Contains(firstRow, "<td class=\"BG2 S\" colspan=\"14\">") {1461 splitData := strings.Split(firstRow, "<td class=\"BG2 S\" colspan=\"14\">")1462 for _,1463 bg2Data := range splitData {1464 utils.WriteValue(bg2Data)1465 if strings.Contains(bg2Data, "<td class=\"BG0 S\" colspan=\"16\">") {1466 split_span16 := strings.Split(bg2Data, "<td class=\"BG0 S\" colspan=\"16\">")1467 for _,1468 row_16 := range split_span16 {1469 trSplitdata := strings.Split(row_16, "<tr>")1470 for _,1471 row := range trSplitdata {1472 utils.WriteValue(row)1473 _index := "0"1474 if strings.Contains(row, "class=\"BG0") {1475 _index = "3"1476 } else if strings.Contains(row, "class=\"BG1") {1477 _index = "4"1478 } else if strings.Contains(row, "class=\"BG2") {1479 _index = "2"1480 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {1481 _index = "3"1482 }1483 val := utils.ParseData(row, _index)1484 if utils.FieldControl(val) {1485 _ListHtml = append(_ListHtml, * val)1486 }1487 }1488 }1489 } else {1490 trSplitdata := strings.Split(bg2Data, "<tr>")1491 for _,1492 row := range trSplitdata {1493 utils.WriteValue(row)1494 _index := "0"1495 if strings.Contains(row, "class=\"BG0") {1496 _index = "3"1497 } else if strings.Contains(row, "class=\"BG1") {1498 _index = "1"1499 } else if strings.Contains(row, "class=\"BG2") {1500 _index = "2"1501 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {1502 _index = "3"1503 }1504 val := utils.ParseData(row, _index)1505 if utils.FieldControl(val) {1506 _ListHtml = append(_ListHtml, * val)1507 }1508 }1509 }1510 }1511 } else if strings.Contains(firstRow, "<td class=\"BG2 S\" colspan=\"13\">") {1512 splitData := strings.Split(firstRow, "<td class=\"BG2 S\" colspan=\"13\">")1513 for _,1514 bg2Data := range splitData {1515 utils.WriteValue(bg2Data)1516 trSplitdata := strings.Split(bg2Data, "<tr>")1517 for _, row := range trSplitdata {1518 utils.WriteValue(row)1519 _index := "0"1520 if strings.Contains(row, "class=\"BG0") {1521 _index = "2"1522 } else if strings.Contains(row, "class=\"BG1") {1523 _index = "1"1524 } else if strings.Contains(row, "class=\"BG2") {1525 _index = "2"1526 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {1527 _index = "3"1528 }1529 val := utils.ParseData(row, _index)1530 if utils.FieldControl(val) {1531 _ListHtml = append(_ListHtml, * val)1532 }1533 }1534 }1535 } else if strings.Contains(firstRow, "<td class=\"BG2 S\" colspan=\"17\">") {1536 splitData := strings.Split(firstRow, "<td class=\"BG2 S\" colspan=\"17\">")1537 for _,1538 bg2Data := range splitData {1539 utils.WriteValue(bg2Data)1540 trSplitdata := strings.Split(bg2Data, "<tr>")1541 for _, row := range trSplitdata {1542 utils.WriteValue(row)1543 _index := "0"1544 if strings.Contains(row, "class=\"BG0") {1545 _index = "2"1546 } else if strings.Contains(row, "class=\"BG1") {1547 _index = "1"1548 } else if strings.Contains(row, "class=\"BG2") {1549 _index = "2"1550 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {1551 _index = "3"1552 }1553 val := utils.ParseData(row, _index)1554 if utils.FieldControl(val) {1555 _ListHtml = append(_ListHtml, * val)1556 }1557 }1558 }1559 } else if strings.Contains(firstRow, "<td class=\"BG0 S\" colspan=\"15\">") {1560 splitbgos15 := strings.Split(firstRow, "<td class=\"BG0 S\" colspan=\"15\">")1561 for _,1562 bgorow := range splitbgos15 {1563 utils.WriteValue(bgorow)1564 if strings.Contains(bgorow, "<td class=\"BG1 S\" colspan=\"16\">") {1565 splitBg016 := strings.Split(bgorow, "<td class=\"BG1 S\" colspan=\"16\">")1566 for _,1567 bg2Data := range splitBg016 {1568 utils.WriteValue(bg2Data)1569 trSplitdata := strings.Split(bg2Data, "<tr>")1570 for _, row := range trSplitdata {1571 utils.WriteValue(row)1572 _index := "0"1573 if strings.Contains(row, "class=\"BG0") {1574 _index = "3"1575 } else if strings.Contains(row, "class=\"BG1") {1576 _index = "4"1577 } else if strings.Contains(row, "class=\"BG2") {1578 _index = "5"1579 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {1580 _index = "3"1581 }1582 val := utils.ParseData(row, _index)1583 if utils.FieldControl(val) {1584 _ListHtml = append(_ListHtml, * val)1585 }1586 }1587 }1588 } else {1589 trSplitdata := strings.Split(bgorow, "<tr>")1590 for _,1591 row := range trSplitdata {1592 utils.WriteValue(row)1593 _index := "0"1594 if strings.Contains(row, "class=\"BG0") {1595 _index = "3"1596 } else if strings.Contains(row, "class=\"BG1") {1597 _index = "4"1598 } else if strings.Contains(row, "class=\"BG2\">") {1599 _index = "5"1600 } else if strings.Contains(row, "class=\"BG2 S") {1601 _index = "2"1602 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {1603 _index = "3"1604 }1605 val := utils.ParseData(row, _index)1606 if utils.FieldControl(val) {1607 _ListHtml = append(_ListHtml, * val)1608 }1609 }1610 }1611 }1612 } else if strings.Contains(firstRow, "<td class=\"BG2 S\" colspan=\"9\">") {1613 splitbgos15 := strings.Split(firstRow, "<td class=\"BG2 S\" colspan=\"9\">")1614 for _,1615 bgorow := range splitbgos15 {1616 trSplitdata := strings.Split(bgorow, "<tr>")1617 for _,1618 row := range trSplitdata {1619 utils.WriteValue(row)1620 _index := "0"1621 if strings.Contains(row, "class=\"BG0") {1622 _index = "2"1623 } else if strings.Contains(row, "class=\"BG1") {1624 _index = "4"1625 } else if strings.Contains(row, "class=\"BG2\">") {1626 _index = "5"1627 } else if strings.Contains(row, "class=\"BG2 S") {1628 _index = "2"1629 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {1630 _index = "3"1631 }1632 val := utils.ParseData(row, _index)1633 if utils.FieldControl(val) {1634 _ListHtml = append(_ListHtml, * val)1635 }1636 }1637 }1638 } else {1639 trSplitdata := strings.Split(firstRow, "<tr>")1640 for _,1641 row := range trSplitdata {1642 utils.WriteValue(row)1643 _index := "0"1644 if strings.Contains(row, "class=\"BG0") {1645 _index = "master"1646 } else if strings.Contains(row, "class=\"BG1") {1647 _index = "1"1648 } else if strings.Contains(row, "class=\"BG2") {1649 _index = "2"1650 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {1651 _index = "3"1652 }1653 val := utils.ParseData(row, _index)1654 if utils.FieldControl(val) {1655 _ListHtml = append(_ListHtml, * val)1656 }1657 }1658 }1659 }1660 } else if (strings.Contains(masterRow, "<td class=\"BG1 S\" colspan=\"13\">")) {1661 split_colspan_16 := strings.Split(masterRow, "<td class=\"BG1 S\" colspan=\"13\">")1662 for _,1663 colspan_firstdata := range split_colspan_16 {1664 utils.WriteValue(colspan_firstdata)1665 if strings.Contains(colspan_firstdata, "<td class=\"BG2 S\" colspan=\"14\">") {1666 utils.WriteValue(colspan_firstdata)1667 split_colspan_14 := strings.Split(colspan_firstdata, "<td class=\"BG2 S\" colspan=\"14\">")1668 for _,1669 colspan_second := range split_colspan_14 {1670 utils.WriteValue(colspan_second)1671 if strings.Contains(colspan_second, "<td class=\"BG0 S\" colspan=\"16\">") {1672 utils.WriteValue(colspan_second)1673 splitData2 := strings.Split(colspan_second, "<td class=\"BG0 S\" colspan=\"16\">")1674 utils.WriteValue("")1675 for _,1676 bg0Data := range splitData2 {1677 utils.WriteValue(bg0Data)1678 trSplitdata := strings.Split(bg0Data, "<tr>")1679 for _, row := range trSplitdata {1680 utils.WriteValue(row)1681 _index := "0"1682 if strings.Contains(row, "class=\"BG0") {1683 _index = "3"1684 } else if strings.Contains(row, "class=\"BG1") {1685 _index = "4"1686 } else if strings.Contains(row, "class=\"BG2\">") {1687 _index = "5"1688 } else if strings.Contains(row, "class=\"BG2 S") {1689 _index = "2"1690 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {1691 _index = "3"1692 }1693 val := utils.ParseData(row, _index)1694 if utils.FieldControl(val) {1695 _ListHtml = append(_ListHtml, * val)1696 }1697 }1698 }1699 } else {1700 trSplitdata := strings.Split(colspan_second, "<tr>")1701 for _,1702 row := range trSplitdata {1703 utils.WriteValue(row)1704 _index := "0"1705 if strings.Contains(row, "class=\"BG0") {1706 _index = "3"1707 } else if strings.Contains(row, "class=\"BG1") {1708 _index = "1"1709 } else if strings.Contains(row, "class=\"BG2") {1710 _index = "2"1711 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {1712 _index = "3"1713 }1714 val := utils.ParseData(row, _index)1715 if utils.FieldControl(val) {1716 _ListHtml = append(_ListHtml, * val)1717 }1718 }1719 }1720 }1721 } else if strings.Contains(colspan_firstdata, "<td class=\"BG2 S\" colspan=\"16\">") {1722 splitData := strings.Split(colspan_firstdata, "<td class=\"BG2 S\" colspan=\"16\">")1723 for _,1724 bg2Data := range splitData {1725 utils.WriteValue(bg2Data)1726 trSplitdata := strings.Split(bg2Data, "<tr>")1727 for _, row := range trSplitdata {1728 utils.WriteValue(row)1729 _index := "0"1730 if strings.Contains(row, "class=\"BG0") {1731 _index = "3"1732 } else if strings.Contains(row, "class=\"BG1") {1733 _index = "1"1734 } else if strings.Contains(row, "class=\"BG2") {1735 _index = "2"1736 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {1737 _index = "3"1738 }1739 val := utils.ParseData(row, _index)1740 if utils.FieldControl(val) {1741 _ListHtml = append(_ListHtml, * val)1742 }1743 }1744 }1745 } else if strings.Contains(colspan_firstdata, "<td class=\"BG2 S\" colspan=\"13\">") {1746 splitData := strings.Split(colspan_firstdata, "<td class=\"BG2 S\" colspan=\"13\">")1747 for _,1748 bg2Data := range splitData {1749 utils.WriteValue(bg2Data)1750 trSplitdata := strings.Split(bg2Data, "<tr>")1751 for _, row := range trSplitdata {1752 utils.WriteValue(row)1753 _index := "0"1754 if strings.Contains(row, "class=\"BG0") {1755 _index = "3"1756 } else if strings.Contains(row, "class=\"BG1") {1757 _index = "1"1758 } else if strings.Contains(row, "class=\"BG2") {1759 _index = "2"1760 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {1761 _index = "3"1762 }1763 val := utils.ParseData(row, _index)1764 if utils.FieldControl(val) {1765 _ListHtml = append(_ListHtml, * val)1766 }1767 }1768 }1769 } else if strings.Contains(colspan_firstdata, "<td class=\"BG2 S\" colspan=\"17\">") {1770 splitData := strings.Split(colspan_firstdata, "<td class=\"BG2 S\" colspan=\"17\">")1771 for _,1772 bg2Data := range splitData {1773 utils.WriteValue(bg2Data)1774 trSplitdata := strings.Split(bg2Data, "<tr>")1775 for _, row := range trSplitdata {1776 utils.WriteValue(row)1777 _index := "0"1778 if strings.Contains(row, "class=\"BG0") {1779 _index = "3"1780 } else if strings.Contains(row, "class=\"BG1") {1781 _index = "1"1782 } else if strings.Contains(row, "class=\"BG2") {1783 _index = "2"1784 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {1785 _index = "3"1786 }1787 val := utils.ParseData(row, _index)1788 if utils.FieldControl(val) {1789 _ListHtml = append(_ListHtml, * val)1790 }1791 }1792 }1793 } else if strings.Contains(colspan_firstdata, "<td class=\"BG2 S\" colspan=\"15\">") {1794 splitData := strings.Split(colspan_firstdata, "<td class=\"BG2 S\" colspan=\"15\">")1795 for _,1796 bg2Data := range splitData {1797 utils.WriteValue(bg2Data)1798 trSplitdata := strings.Split(bg2Data, "<tr>")1799 for _, row := range trSplitdata {1800 utils.WriteValue(row)1801 _index := "0"1802 if strings.Contains(row, "class=\"BG0") {1803 _index = "3"1804 } else if strings.Contains(row, "class=\"BG1") {1805 _index = "1"1806 } else if strings.Contains(row, "class=\"BG2") {1807 _index = "2"1808 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {1809 _index = "3"1810 }1811 val := utils.ParseData(row, _index)1812 if utils.FieldControl(val) {1813 _ListHtml = append(_ListHtml, * val)1814 }1815 }1816 }1817 } else {1818 trSplitdata := strings.Split(colspan_firstdata, "<tr>")1819 for _,1820 row := range trSplitdata {1821 utils.WriteValue(row)1822 _index := "0"1823 if strings.Contains(row, "class=\"BG0") {1824 _index = "master"1825 } else if strings.Contains(row, "class=\"BG1") {1826 _index = "1"1827 } else if strings.Contains(row, "class=\"BG2") {1828 _index = "2"1829 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {1830 _index = "3"1831 }1832 val := utils.ParseData(row, _index)1833 if utils.FieldControl(val) {1834 _ListHtml = append(_ListHtml, * val)1835 }1836 }1837 }1838 }1839 } else {1840 trSplitdata := strings.Split(masterRow, "<tr>")1841 for _,1842 row := range trSplitdata {1843 utils.WriteValue(row)1844 _index := "0"1845 if strings.Contains(row, "class=\"BG0") {1846 _index = "master"1847 } else if strings.Contains(row, "class=\"BG1") {1848 _index = "1"1849 } else if strings.Contains(row, "class=\"BG2") {1850 _index = "2"1851 } else if strings.Contains(row, "<td class=\"BG0 R FP1\">") {1852 _index = "3"1853 }1854 val := utils.ParseData(row, _index)1855 if utils.FieldControl(val) {1856 _ListHtml = append(_ListHtml, * val)1857 }1858 }1859 }1860 }1861 return _ListHtml1862}1863func ConverToMasterDto(dto models.ConvertMasterDto) * models.MasterProduct {1864 result := models.MasterProduct {}1865 result.Tipi = dto.E.Col11866 result.Uy = dto.E.Col31867 result.Processid = dto.UniqueID1868 result.MasterKod = dto.E.Col41869 result.Aciklama = dto.E.Col51870 result.Tedarikci = dto.E.Col61871 result.Fiyat = dto.E.Col71872 result.Parabirimi = dto.E.Col81873 result.FileName = dto.FileName1874 result.PackageCretaDate = dto.PackageCreataDate1875 result.PackageNumber = dto.PackageNumber1876 return &result1877}1878func ConverToDetailDto(dto models.ConvertDetailDto) * models.DetailProduct {1879 r := models.DetailProduct {}1880 1881 r = col3(dto.E, dto.H, "")1882 r.Processid = dto.UniqueID1883 r.MasterKod = dto.MasterCode1884 r.MasteriId = dto.Masterid1885 r.DetayId = dto.Dept1886 r.PaketNumarasi = dto.PackageNumber1887 r.PaketTarihi = dto.PackageCreataDate1888 return &r1889}1890func col3(d models.ExcelDto, h models.ExcelDto, _type string) models.DetailProduct {1891 r := models.DetailProduct {}1892 r.Tipi = d.Col11893 //col3 1894 ////--------Col1----------------- 1895 if h.Col1 == "Açıklama" {1896 r.Aciklama = d.Col11897 }1898 ////--------Col2----------------- 1899 if h.Col2 == "Esk.Formülü" {1900 r.EskFormülü = d.Col21901 } else if h.Col2 == "Açıklama" {1902 r.Aciklama = d.Col21903 }else1904 ////--------Col3----------------- 1905 if h.Col3 == "Malzeme" {1906 r.Malzeme = d.Col31907 } else if h.Col3 == "Esk.Formülü" {1908 r.EskFormülü = d.Col31909 } else if h.Col3 == "Fiyat" {1910 r.Fiyat = d.Col31911 }1912 ////--------Col4----------------- 1913 if h.Col4 == "Açıklama" {1914 r.Aciklama = d.Col41915 } else if h.Col4 == "Mlyt(Sa)" {1916 r.Maliyetsa = d.Col41917 } else if h.Col4 == "Malzeme" {1918 r.Malzeme = d.Col41919 }1920 ////--------Col5----------------- 1921 if h.Col5 == "Sarf" {1922 r.Sarf = d.Col51923 } else if h.Col5 == "Tedarikçi" {1924 r.Tedarikci = d.Col51925 } else if h.Col5 == "Op.Süresi(dk)" {1926 r.OpSuresi = d.Col51927 } else if h.Col5 == "Açıklama" {1928 r.Aciklama = d.Col51929 }1930 ////--------Col6----------------- 1931 if h.Col6 == "Brm" {1932 r.Brm = d.Col61933 } else if h.Col6 == "Fire" {1934 r.Fire = d.Col61935 } else if h.Col6 == "Fiyat" {1936 r.Fiyat = d.Col61937 } else if h.Col6 == "Çvrm. Adt" {1938 r.ÇevrimAdet = d.Col61939 } else if h.Col6 == "Tedarikçi" {1940 r.Tedarikci = d.Col61941 }1942 ////--------Col7----------------- 1943 if h.Col7 == "MMO%" {1944 r.MMO = d.Col71945 } else if h.Col7 == "Brm" {1946 r.Brm = d.Col71947 } else if h.Col7 == "Pros.Net" {1948 r.ProsNet = d.Col71949 } else if h.Col7 == "Fiyat" {1950 r.Fiyat = d.Col71951 }1952 ////--------Col8----------------- 1953 if h.Col8 == "PMO%" {1954 r.PMO = d.Col81955 } else if h.Col8 == "MMO%" {1956 r.MMO = d.Col81957 } else if h.Col8 == "Pros.Net" {1958 r.Prosfile = d.Col81959 } else if h.Col8 == "P.Brm" {1960 r.Brm = d.Col81961 }1962 ////--------Col9----------------- 1963 if h.Col9 == "PFO%" {1964 r.PFO = d.Col91965 } else if h.Col9 == "PMO%" {1966 r.PMO = d.Col91967 } else if h.Col9 == "Pros." {1968 r.Pros = d.Col91969 }1970 ////--------Col10----------------- 1971 if h.Col10 == "Esk.Formülü" {1972 r.EskFormülü = d.Col101973 } else if h.Col10 == "Malz." {1974 r.Malz = d.Col101975 } else if h.Col10 == "FO T." {1976 r.FOT = d.Col101977 } else if h.Col10 == "PFO%" {1978 r.PFO = d.Col101979 }1980 ////--------Col11----------------- 1981 if h.Col11 == "FO T." {1982 r.FOT = d.Col111983 } else if h.Col11 == "Malz." {1984 r.Malz = d.Col111985 } else if h.Col11 == "Pros." {1986 r.Pros = d.Col111987 }1988 ////--------Col12----------------- 1989 if h.Col12 == "FO T." {1990 r.FOT = d.Col121991 } else if h.Col12 == "Fiyat" {1992 r.Fiyat = d.Col121993 } else if h.Col12 == "Pros." {1994 r.Pros = d.Col121995 }1996 ////--------Col13----------------- 1997 if h.Col13 == "MO T." {1998 r.MOT = d.Col131999 } else if h.Col13 == "Pros." {2000 r.Pros = d.Col132001 } else if h.Col13 == "Fiyat" {2002 r.Fiyat = d.Col132003 }2004 ////--------Col14----------------- 2005 if h.Col14 == "MO T." {2006 r.MOT = d.Col142007 } else if h.Col14 == "Fiyat" {2008 r.Fiyat = d.Col142009 }2010 ////--------Col15----------------- 2011 if h.Col15 == "Fiyat" {2012 r.Fiyat = d.Col152013 }2014 return r2015}2016// func mlzControl(r models.DetailProduct, e models.ExcelDto, dept string) models.DetailProduct {2017// if dept == "Col10" {2018// r.Tipi = e.Col12019// r.Malzeme = e.Col32020// r.Aciklama = e.Col42021// r.Sarf = e.Col52022// r.Brm = e.Col62023// r.MMO = e.Col72024// r.PMO = e.Col82025// r.PFO = e.Col92026// r.Malz = e.Col102027// r.FOT = e.Col112028// r.Pros = e.Col122029// r.MOT = e.Col132030// r.Fiyat = e.Col142031// }2032// return r2033// }2034// func ToplControl(r models.DetailProduct, e models.ExcelDto, dept string) models.DetailProduct {2035// if e.Col4 == "Topl." {2036// r.Toplam = e.Col42037// if e.Col14 == ""{2038// r.Fiyat = e.Col152039// }else{2040// r.Fiyat = e.Col142041// }2042// }2043// return r2044// }2045// func malzemeControl(r models.DetailProduct, e models.ExcelDto, dept string) models.DetailProduct {2046// if e.Col10 == "Esk.Formülü" {2047// r.Tipi = e.Col12048// r.Malzeme = e.Col32049// r.Aciklama = e.Col42050// r.Sarf = e.Col52051// r.Brm = e.Col62052// r.MMO = e.Col72053// r.PMO = e.Col82054// r.PFO = e.Col92055// r.EskFormülü = e.Col102056// r.Malz = e.Col112057// r.FOT = e.Col122058// r.Pros = e.Col132059// r.MOT = e.Col142060// r.Fiyat = e.Col152061// }else if e.Col0 == "Malz." {2062// }else if e.Col0 == "FOT." {2063// }2064// return r2065// }2066// func AciklamaControl(r models.DetailProduct, e models.ExcelDto, dept string) models.DetailProduct {2067// if dept == "Col2" {2068// r.Tipi = e.Col12069// r.Aciklama = e.Col22070// r.EskFormülü = e.Col32071// r.Maliyetsa = e.Col42072// r.OpSuresi = e.Col52073// r.ÇevrimAdet = e.Col62074// r.ProsNet = e.Col72075// r.Prosfile = e.Col82076// r.Pros = e.Col92077// }2078// return r2079// }2080// func ConverToDetailDto1(orders models.ExcelDto, uniqueID string, masterid uint64, detayid string, header models.ExcelDto, masterCode string) *models.DetailProduct {2081// insertType := utils.GetInsertType(orders)2082// utils.WriteValue(insertType)2083// utils.WriteValue(header.Col5)2084// result := models.DetailProduct{}2085// result.MasteriId = masterid2086// result.Processid = uniqueID2087// result.MasterKod = masterCode2088// result.DetayId = detayid2089// result.Tipi = orders.Col12090// if insertType == "none" {2091// result.Malzeme = orders.Col32092// result.Aciklama = orders.Col42093// result.Sarf = orders.Col52094// //-------col6-----------------------2095// if header.Col6 == "Fire" {2096// result.Fire = orders.Col62097// }2098// if header.Col6 == "Brm" {2099// result.Brm = orders.Col62100// }2101// //-------col7-----------------------2102// if header.Col7 == "Brm" {2103// result.Brm = orders.Col72104// }2105// if header.Col7 == "MMO%" {2106// result.MMO = orders.Col72107// }2108// //-------col8-----------------------2109// if header.Col8 == "MMO%" {2110// result.MMO = orders.Col82111// }2112// if header.Col8 == "PMO%" {2113// result.PMO = orders.Col82114// }2115// //-------col9-----------------------2116// if header.Col9 == "PMO%" {2117// result.PMO = orders.Col92118// }2119// if header.Col9 == "PFO%" {2120// result.PFO = orders.Col92121// }2122// //-------col10-----------------------2123// if header.Col10 == "PFO%" {2124// result.PFO = orders.Col102125// }2126// if header.Col10 == "Esk.Formülü" {2127// result.EskFormülü = orders.Col102128// }2129// } else if insertType == "Proses" {2130// result.Aciklama = orders.Col22131// result.EskFormülü = orders.Col32132// result.Maliyetsa = orders.Col42133// result.OpSuresi = orders.Col52134// result.ÇevrimAdet = orders.Col62135// result.ProsNet = orders.Col72136// result.Prosfile = orders.Col82137// result.Pros = orders.Col92138// } else {2139// result.Aciklama = orders.Col42140// }2141// if insertType == "op" {2142// result.PMO = orders.Col92143// result.PFO = orders.Col102144// result.FOT = orders.Col122145// result.Pros = orders.Col132146// result.MOT = orders.Col142147// result.Fiyat = orders.Col152148// }2149// if header.Col5 == "Tedarikçi" {2150// result.Tipi = orders.Col22151// result.Malzeme = orders.Col32152// result.Aciklama = orders.Col42153// result.Tedarikci = orders.Col52154// result.Fiyat = orders.Col62155// }2156// if insertType == "none" {2157// result.Malz = orders.Col122158// result.FOT = orders.Col122159// result.Pros = orders.Col132160// result.MOT = orders.Col142161// result.Fiyat = orders.Col152162// }2163// if insertType == "Topl" {2164// result.Aciklama = orders.Col12165// result.Fiyat = orders.Col32166// }2167// if insertType == "adetay" {2168// result.Aciklama = orders.Col42169// result.EskFormülü = orders.Col112170// }2171// if insertType == "Topl_4" {2172// result.Aciklama = orders.Col42173// result.EskFormülü = orders.Col62174// }2175// if insertType == "Ambalaj" {2176// result.EskFormülü = strings.ReplaceAll(orders.Col2, "*[TRY]", "")2177// result.Fiyat = orders.Col32178// }2179// if(header.Col2 == "Esk.Formülü"){2180// result.Aciklama = orders.Col12181// result.EskFormülü = orders.Col22182// result.Fiyat = orders.Col32183// }2184// if(header.Col3 == "Esk.Formülü"){2185// result.Aciklama = orders.Col22186// result.EskFormülü = orders.Col32187// result.Maliyetsa = orders.Col42188// result.OpSuresi = orders.Col52189// result.ÇevrimAdet = orders.Col62190// result.ProsNet = orders.Col72191// result.Prosfile = orders.Col82192// result.Pros = orders.Col92193// }2194// return &result2195// }2196func GetHeaderData(data string)(string, string) {2197 hedarData := utils.GetDataFromHtml(data, "html body table tr td table")2198 hedarData = strings.ReplaceAll(hedarData, "</td>", "</td>\n")2199 // hedarData = strings.ReplaceAll(hedarData,"<tbody>","")2200 // hedarData = strings.ReplaceAll(hedarData,"<td=\"\"","")2201 // hedarData = strings.ReplaceAll(hedarData,"<tr>","")2202 // hedarData = strings.ReplaceAll(hedarData,"</tr>","")2203 // hedarData = strings.ReplaceAll(hedarData,"</tbody>","")2204 re := regexp.MustCompile(`<td.*?>(.*)</td>`)2205 res := re.FindAllStringSubmatch(hedarData, -1)2206 return res[2][1],2207 res[8][1]2208}...

Full Screen

Full Screen

main.go

Source:main.go Github

copy

Full Screen

1package main2import (3 "fmt"4 "github.com/icewind666/html-to-excel-renderer/src/generator"5 "github.com/icewind666/html-to-excel-renderer/src/types"6 "github.com/jbowtie/gokogiri"7 "github.com/jbowtie/gokogiri/xml"8 "github.com/jbowtie/gokogiri/xpath"9 "github.com/jessevdk/go-flags"10 log "github.com/sirupsen/logrus"11 _ "image"12 _ "image/jpeg"13 _ "image/png"14 "io/ioutil"15 "os"16 "os/exec"17 "runtime"18 "strconv"19 "strings"20 "time"21)22var (23 version = "1.2.4"24 date = "02.12.2021"25 builtBy = "v.korennoj@medpoint24.ru"26)27// XpathTable Search strings for html tags28var XpathTable = xpath.Compile(".//table")29var XpathThead = xpath.Compile(".//thead/tr")30var XpathTh = xpath.Compile(".//th")31var XpathTr = xpath.Compile("./tr")32var XpathTd = xpath.Compile(".//td")33var XpathImg = xpath.Compile(".//img")34var opts struct {35 Version bool `long:"version" description:"Show current version"`36 UseHandleBars bool `long:"handlebars" description:"Use Handlebars template engine"`37 Output string `long:"output" description:"Output xslx filepath"`38 TemplateFile string `long:"template" description:"A Handlebars template file"`39 DataFile string `long:"data" description:"A json data file. Used with handlebars rendering"`40 HtmlFile string `long:"html" description:"Html rendered source file"`41 BatchSize int `long:"batch-size" description:"Max rows for one iteration. Smaller size leads to smaller amount of memory used"`42 PxWidthToExcel float64 `long:"px-width" description:"Multiplier used to map pixels in html to width in excel"`43 PxHeightToExcel float64 `long:"px-height" description:"Multiplier used to map pixels in html to height in excel"`44 HelpersPath string `long:"helpers" description:"Path to helpers folder. Used with handlebars rendering"`45 DebugMode bool `long:"debug" description:"Enable debug mode. Default is false"`46 LogLevel string `long:"log-level" description:"Log level(info, warn, debug...). Default is info"`47}48func main() {49 log.SetOutput(os.Stdout)50 _,err := flags.Parse(&opts)51 if err != nil {52 log.WithError(err).Error("Can't parse command line arguments")53 }54 showVersion := opts.Version55 if showVersion {56 fmt.Println(version)57 os.Exit(0)58 }59 log.Infof("html-to-excel-renderer v%s, built at %s by %s", version, date, builtBy)60 useHandlebars := opts.UseHandleBars61 template := opts.TemplateFile62 htmlFile := opts.HtmlFile63 data := opts.DataFile64 output := opts.Output65 debugMode := opts.DebugMode66 batchSize := opts.BatchSize67 if opts.PxWidthToExcel <= 0 {68 opts.PxWidthToExcel = 0.15 // default69 }70 if opts.PxHeightToExcel <= 0 {71 opts.PxHeightToExcel = 0.10 // default72 }73 if runtime.GOOS == "windows" && useHandlebars {74 log.Fatalf("Current version does not support using Handlebars on Windows systems! Sorry! Will be fixed in next version")75 }76 if useHandlebars && opts.HelpersPath == "" {77 log.Error("Using Handlebars without setting helpers path will likely cause errors! Hope your template does not contain helpers :)")78 } else {79 opts.HelpersPath += "/*.js"80 }81 if batchSize <= 0 {82 batchSize = 10_000_00083 }84 logLevel,err := log.ParseLevel(opts.LogLevel)85 if err != nil {86 log.Warn("Debug level set to info (default value)")87 log.SetLevel(log.InfoLevel)88 } else {89 log.SetLevel(logLevel)90 }91 if debugMode {92 log.Infoln("Debug mode is ON (will write MUCH MORE logs!!)")93 }94 renderedHtml := ""95 defer timeTrack(time.Now(), "main")96 if useHandlebars {97 renderedHtml = applyHbsRendering(template, data, opts.HelpersPath)98 log.Infoln("Rendering Handlebars.js template to html is done")99 } else {100 renderedHtml = ReadHtmlFile(htmlFile)101 log.Infoln("Reading html is done")102 }103 generateXlsxFile(renderedHtml, output, batchSize)104 PrintMemUsage()105 log.Infoln("All done")106}107func NewHtmlStyle() *types.HtmlStyle {108 return &types.HtmlStyle {109 TextAlign: "",110 WordWrap: false,111 Width: 0,112 Height: 0,113 BorderInheritance: false,114 BorderStyle: false,115 FontSize: 0,116 IsBold: false,117 Colspan: 0,118 VerticalAlign: "",119 CellValueType: StringValueType,120 BackgroundColor: "",121 }122}123// ReadHtmlFile Read and return file contents as string124func ReadHtmlFile(htmlFilename string) string {125 byteValue, _ := ioutil.ReadFile(htmlFilename)126 if htmlFilename == "" {127 log.Fatalln("Html file is not specified(--html)")128 }129 if byteValue == nil {130 log.Fatalf("Html file is empty? %s", htmlFilename)131 }132 return string(byteValue)133}134func NewExcelizeGenerator() *generator.ExcelizeGenerator {135 return &generator.ExcelizeGenerator{136 OpenedFile: nil,137 Filename: "",138 CurrentSheet: "",139 CurrentCol: 0,140 CurrentRow: 0,141 }142}143// Parses given html and generates xslt file.144// File is generated by adding batches of batchSize to in on every iteration.145func generateXlsxFile(html string, outputFilename string, batchSize int) string {146 defer timeTrack(time.Now(), "generateXlsxFile")147 doc, err := gokogiri.ParseHtml([]byte(html))148 if err != nil {149 log.WithError(err).Fatalln("Parse html ERROR!")150 }151 tables, _ := doc.Root().Search(XpathTable)152 defer doc.Free()153 // creating excel excelizeGenerator154 excelizeGenerator := NewExcelizeGenerator()155 excelFilename := fmt.Sprintf("%s", outputFilename)156 excelizeGenerator.Filename = excelFilename157 excelizeGenerator.CurrentCol = 1158 excelizeGenerator.CurrentRow = 1159 excelizeGenerator.Create()160 totalRows := 0161 currentSheetIndex := 0162 // Main cycle through all tables in file163 for i, table := range tables {164 // Create new sheet for each table. Name it with data-name from html attribute165 sheetName := table.Attr("data-name")166 if sheetName == "" {167 sheetName = fmt.Sprintf("DataSheet %d", i)168 log.Infof("Warning! No data-name in for table found. Used %s as sheet name\n", sheetName)169 }170 if currentSheetIndex == 0 {171 excelizeGenerator.SetSheetName("Sheet1", sheetName)172 } else {173 excelizeGenerator.AddSheet(sheetName)174 }175 excelizeGenerator.CurrentCol = 1176 excelizeGenerator.CurrentRow = 0177 // Get thead for table and create header in xlsx178 theadTrs, _ := table.Search(XpathThead)179 processHtmlTheadTag(theadTrs, excelizeGenerator)180 // Get all rows in html table181 rows, _ := table.Search(XpathTr)182 rowsProceeded := 0183 packSize := batchSize184 for rowsProceeded < len(rows) {185 processTableRows(rows, excelizeGenerator, rowsProceeded, packSize)186 rowsProceeded += packSize187 }188 totalRows += len(rows) // stored only for log output189 rows = nil // just for sure. prevent memory leak which was found during tests in 3rd party lib190 currentSheetIndex += 1191 }192 excelizeGenerator.Save(excelizeGenerator.Filename)193 log.Infof("Total rows done: %d", totalRows)194 return excelFilename195}196// processTableRows Process all html table rows. Starts with <th> table headers then goes over <tr> and <td> inside them.197func processTableRows(rows []xml.Node, generator *generator.ExcelizeGenerator, offset int, rowsNumber int) {198 defer timeTrack(time.Now(), "processTableRows")199 if offset >= len(rows) {200 return // offset cant be greater than number of rows201 }202 if len(rows) < rowsNumber {203 rowsNumber = len(rows) // when less than one page204 }205 for i := offset; i <= (offset + rowsNumber - 1); i++ {206 if i >= len(rows) {207 break // we are done here208 }209 tr := rows[i]210 generator.AddRow()211 theadTrs, _ := tr.Search(XpathTh)212 generator.CurrentCol = 1213 // <th>214 for _, theadTh := range theadTrs {215 thStyle := theadTh.Attribute(StyleAttrName)216 cellValue := theadTh.Content()217 if thStyle != nil {218 style := ExtractStyles(thStyle)219 thColspan := theadTh.Attribute(ColspanAttrName)220 if thColspan != nil {221 style.Colspan,_ = strconv.Atoi(thColspan.Value())222 generator.ApplyBordersRange(style)223 }224 generator.ApplyColumnStyle(style)225 generator.ApplyCellStyle(style)226 }227 // <img>228 // NOTE: is it valid to have img in th?)229 imgs, _ := theadTh.Search(XpathImg)230 if len(imgs) > 0 {231 for _, img := range imgs {232 addImageToCell(img, generator)233 }234 } else {235 if cellValue != "" {236 generator.SetCellValue(cellValue)237 }238 }239 generator.CurrentCol += 1240 }241 cells, _ := tr.Search(XpathTd)242 generator.CurrentCol = 1243 // table td cells244 for _, td := range cells {245 tdStyle := td.Attribute("style")246 cellValue := td.Content()247 cellValueType := StringValueType248 if tdStyle != nil {249 cellStyle := ExtractStyles(tdStyle)250 tdColspan := td.Attribute(ColspanAttrName)251 cellValueType = cellStyle.CellValueType252 if tdColspan != nil {253 cellStyle.Colspan,_ = strconv.Atoi(tdColspan.Value())254 generator.ApplyBordersRange(cellStyle)255 }256 generator.ApplyCellStyle(cellStyle)257 }258 imgs, _ := td.Search(XpathImg)259 if len(imgs) > 0 {260 for _, img := range imgs {261 addImageToCell(img, generator)262 }263 } else {264 if cellValue != "" {265 switch cellValueType {266 case FloatValueType:267 floatContent,err := strconv.ParseFloat(cellValue, 64)268 if err != nil {269 log.WithError(err).Error("Cant parse cell type")270 }271 generator.SetCellFloatValue(floatContent)272 case BooleanValueType:273 boolContent, err := strconv.ParseBool(cellValue)274 if err != nil {275 log.WithError(err).Error("Cant parse bool value from string")276 }277 generator.SetCellBoolValue(boolContent)278 default:279 generator.SetCellValue(cellValue)280 }281 }282 }283 generator.CurrentCol += 1284 }285 trStyle := tr.Attribute("style")286 // Apply row style if present287 if trStyle != nil {288 styleExtracted := ExtractStyles(trStyle)289 generator.ApplyRowStyle(styleExtracted)290 }291 }292}293// addImageToCell Inserts image to current cell. Or its alternative text294func addImageToCell(img xml.Node, generator *generator.ExcelizeGenerator) {295 imgSrc := img.Attribute("src")296 imgAlt := img.Attribute("alt")297 // If file exist - set image to cell298 if _, err := os.Stat(imgSrc.Value()); os.IsNotExist(err) {299 if err != nil {300 log.WithError(err).Errorln("Cant access image file")301 }302 generator.SetCellValue(imgAlt.Value())303 }304 currentCellCoords, errCoords := generator.GetCoords()305 if errCoords != nil {306 log.WithError(errCoords).Errorln(errCoords)307 }308 errAdd := generator.OpenedFile.AddPicture(generator.CurrentSheet,309 currentCellCoords,310 imgSrc.Value(),311 `{"autofit":true, "lock_aspect_ratio": true, "positioning": "oneCell"}`)312 if errAdd != nil {313 log.Printf(errAdd.Error())314 }315}316// processHtmlTheadTag Process thead tag (thead->tr + thead->tr->th). Apply column styles. Apply cell styles317func processHtmlTheadTag(theadTrs []xml.Node, generator *generator.ExcelizeGenerator) {318 defer timeTrack(time.Now(), "processHtmlTheadTag")319 for _, theadTr := range theadTrs {320 generator.AddRow()321 theadTrThs, _ := theadTr.Search(XpathTh) // search for <th>322 colIndex := 1323 for _, theadTh := range theadTrThs { // for each <th> in <tr>324 thStyle := theadTh.Attribute(StyleAttrName)325 style := ExtractStyles(thStyle)326 thColspan := theadTh.Attribute(ColspanAttrName)327 if thColspan != nil {328 style.Colspan, _ = strconv.Atoi(thColspan.Value())329 generator.ApplyBordersRange(style)330 }331 content := theadTh.Content()332 if content != "" {333 switch style.CellValueType {334 case FloatValueType:335 floatContent,err := strconv.ParseFloat(content, 64)336 if err != nil {337 log.WithError(err).Error("Cant parse cell type")338 }339 generator.SetCellFloatValue(floatContent)340 case BooleanValueType:341 boolContent, err := strconv.ParseBool(content)342 if err != nil {343 log.WithError(err).Error("Cant parse bool value from string")344 }345 generator.SetCellBoolValue(boolContent)346 default:347 generator.SetCellValue(content)348 }349 }350 if style != nil {351 log.Infoln("ApplyColumnStyle")352 generator.ApplyColumnStyle(style)353 generator.ApplyCellStyle(style)354 }355 colIndex++356 }357 thStyle := theadTr.Attribute(StyleAttrName)358 if thStyle != nil {359 rowStyle := ExtractStyles(thStyle)360 log.Infoln(thStyle)361 thColspan := thStyle.Attribute(ColspanAttrName)362 log.Infoln("colspan", thColspan)363 if thColspan != nil {364 log.Infoln("Applying row colspan")365 rowStyle.Colspan, _ = strconv.Atoi(thColspan.Value())366 }367 if rowStyle != nil {368 log.Infoln("Applying row style")369 generator.ApplyRowStyle(rowStyle)370 }371 } else {372 log.Infoln("No row style found")373 }374 }375}376// applyHbsRendering Calls shell hbs-cli to process handlebars.js template377func applyHbsRendering(templateFilename string, dataFilename string, helpersPath string) string {378 defer timeTrack(time.Now(), "applyHbsRendering")379 args := []string{"--helper", helpersPath, "--data", dataFilename, templateFilename, "--stdout"}380 cmd := exec.Command("hbs", args...)381 outStr, err := cmd.Output()382 if err != nil {383 log.WithError(err).Fatal("Can't run hbs shell command!")384 }385 if opts.DebugMode {386 err := ioutil.WriteFile("./debug.html", outStr, 0777)387 if err != nil {388 log.Warn("Can't write debug html file!")389 }390 }391 return string(outStr)392}393// ExtractStyles Returns parsed style struct394func ExtractStyles(node *xml.AttributeNode) *types.HtmlStyle {395 if node == nil {396 return NewHtmlStyle()397 }398 styleStr := node.Content()399 entries := strings.Split(styleStr, ";")400 resultStyle := NewHtmlStyle()401 for _, e := range entries {402 if e != "" {403 parts := strings.Split(e, ":")404 if len(parts) < 2 {405 continue406 }407 value := strings.Trim(parts[1], " ")408 attr := strings.Trim(parts[0], " ")409 switch attr {410 case ColspanAttrName:411 resultStyle.Colspan, _ = strconv.Atoi(value)412 case TextAlignStyleAttr:413 resultStyle.TextAlign = value414 case WordWrapStyleAttr:415 resultStyle.WordWrap = value == BreakWordWrapStyleAttrValue416 case WidthStyleAttr:417 widthEntry := strings.Trim(value, " px")418 widthInt, _ := strconv.Atoi(widthEntry)419 translatedWidth := float64(widthInt) * opts.PxWidthToExcel420 resultStyle.Width = translatedWidth421 case MinWidthStyleAttr:422 if resultStyle.Width <= 0 {423 widthEntry := strings.Trim(value, " px")424 widthInt, _ := strconv.Atoi(widthEntry)425 translatedWidth := float64(widthInt) * opts.PxWidthToExcel426 resultStyle.Width = translatedWidth427 }428 case MaxWidthStyleAttr:429 if resultStyle.Width <= 0 {430 widthEntry := strings.Trim(value, " px")431 widthInt, _ := strconv.Atoi(widthEntry)432 translatedWidth := float64(widthInt) * opts.PxWidthToExcel433 resultStyle.Width = translatedWidth434 }435 case HeightStyleAttr:436 heightEntry := strings.Trim(value, " px")437 heightInt, _ := strconv.Atoi(heightEntry)438 translatedHeight := float64(heightInt) * opts.PxHeightToExcel439 resultStyle.Height = translatedHeight440 case MinHeightStyleAttr:441 if resultStyle.Height <= 0 {442 heightEntry := strings.Trim(value, " px")443 heightInt, _ := strconv.Atoi(heightEntry)444 translatedHeight := float64(heightInt) * opts.PxHeightToExcel445 resultStyle.Height = translatedHeight446 }447 case MaxHeightStyleAttr:448 if resultStyle.Height <= 0 {449 heightEntry := strings.Trim(value, " px")450 heightInt, _ := strconv.Atoi(heightEntry)451 translatedHeight := float64(heightInt) * opts.PxHeightToExcel452 resultStyle.Height = translatedHeight453 }454 case BorderStyleAttr:455 resultStyle.BorderStyle = value == BorderStyleAttrValue456 case BorderInheritanceStyleAttr:457 resultStyle.BorderStyle = value == BorderInheritanceStyleAttrValue458 case FontSizeStyleAttr:459 widthEntry := strings.Trim(value, " px")460 sz,_ := strconv.Atoi(widthEntry)461 resultStyle.FontSize = float64(sz)462 case FontWeightStyleAttr:463 resultStyle.IsBold = strings.Contains(value, "bold")464 case TextVerticalAlignStyleAttr:465 if value == "middle" {466 value = "center" // excelize lib dont understand middle :) center works fine467 }468 resultStyle.VerticalAlign = value469 case ValueTypeAttrName:470 cellType := types.ValueType(value)471 if cellType == "float" {472 resultStyle.CellValueType = cellType473 }474 if cellType == "bool" {475 resultStyle.CellValueType = cellType476 }477 case BackgroundColorAttrName:478 resultStyle.BackgroundColor = value479 }480 }481 }482 return resultStyle483}484// PrintMemUsage outputs the current, total and OS memory being used. As well as the number485// of garage collection cycles completed.486func PrintMemUsage() {487 var m runtime.MemStats488 runtime.ReadMemStats(&m)489 // For info on each, see: https://golang.org/pkg/runtime/#MemStats490 log.Infof("Alloc = %v MiB, HeapAlloc = %v MiB, Sys = %v MiB", bToMb(m.Alloc),491 bToMb(m.HeapAlloc), bToMb(m.Sys))492}493// bToMb Converts bytes to human readable file size494func bToMb(b uint64) uint64 {495 return b / 1024 / 1024496}497func timeTrack(start time.Time, name string) {498 if opts.DebugMode {499 elapsed := time.Since(start)500 log.Printf("%s took %s", name, elapsed)501 }502}...

Full Screen

Full Screen

statistics.go

Source:statistics.go Github

copy

Full Screen

1package main2import (3 "fmt"4 "io"5 "net/http"6 "sort"7 "strconv"8 "strings"9)10func FormServer(w http.ResponseWriter, request *http.Request) {11 w.Header().Set("Content-Type", "text/html")12 switch request.Method {13 case "GET":14 /* display the form to the user */15 io.WriteString(w, form)16 case "POST":17 intarr := make([]float64, 0)18 for _, item := range strings.Split(request.FormValue("in"), " ") {19 num, _ := strconv.ParseFloat(item, 6)20 intarr = append(intarr, num)21 }22 io.WriteString(w, fmt.Sprintf("<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"UTF-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=\"1.0\"><title>Document</title></head><body><h1>Statistics</h1><p>Computes basic statistics for a given list of numbers</p><text>Numbers(comma or space-separared)</text><form action=\"/\" name=\"bar\" method=\"post\"><input type=\"text\" name=\"in\" /><br/><input type=\"submit\" value=\"calculate\"/></form><br><table border=\"1px\"><tbody><th colspan=\"3\">Result</th><tr><td> Numbers </td><td colspan=\"2\">%v</td></tr><tr><td> Count </td><td colspan=\"2\">%d</td></tr><tr><td> Mean </td><td colspan=\"2\">%f</td></tr><tr><td> Median </td><td colspan=\"2\">%f</td></tr></tbody></table></body></html>", request.FormValue("in"), len(intarr), Mean(intarr), Median(intarr)))23 }24}25func main() {26 http.HandleFunc("/", FormServer)27 if err := http.ListenAndServe(":8088", nil); err != nil {28 panic(err)29 }30}31func Mean(s []float64) float64 {32 sum := 0.033 for _, item := range s {34 sum += item35 }36 return sum / float64(len(s))37}38func Median(s []float64) float64 {39 if len(s) <= 0 {40 return 041 }42 sort.Float64s(s)43 for {44 if len(s) == 2 {45 return (s[0] + s[1]) / 246 } else if len(s) == 1 {47 return s[0]48 }49 if len(s) <= 0 {50 return 051 }52 s = s[1 : len(s)-1]53 }54}55const form = `56<!DOCTYPE html>57<html lang="en">58<head>59 <meta charset="UTF-8">60 <meta name="viewport" content="width=device-width, initial-scale=1.0">61 <title>Document</title>62</head>63<body>64 <h1>Statistics</h1>65 <p>Computes basic statistics for a given list of numbers</p>66 <text>Numbers(comma or space-separared)</text>67 <form action="/" name="bar" method="post">68 <input type="text" name="in" />69 <br/>70 <input type="submit" value="calculate"/>71 </form>72 <br>73 <table border="1px">74 <tbody>75 <th colspan="3">76 Result77 </th>78 <tr>79 <td> Numbers </td>80 <td colspan="2">1 2 3 4 5</td>81 </tr>82 <tr>83 <td> Count </td>84 <td colspan="2">5</td>85 </tr>86 <tr>87 <td> Mean </td>88 <td colspan="2">3</td>89 </tr>90 <tr>91 <td> Median </td>92 <td colspan="2">3</td>93 </tr>94 </tbody>95 </table>96</body>97</html>98`...

Full Screen

Full Screen

ColSpan

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println(html.EscapeString("Hello, <script>alert('world')</script>"))4 fmt.Println(html.UnescapeString("Hello, &lt;script&gt;alert(&#39;world&#39;)&lt;/script&gt;"))5}6Hello, &lt;script&gt;alert(&#39;world&#39;)&lt;/script&gt;7Hello, <script>alert('world')</script>8import (9func main() {10 t, _ := template.New("foo").Parse(`{{define "T"}}Hello, {{.}}!{{end}}`)11 t.ExecuteTemplate(os.Stdout, "T", "<script>alert('you have been pwned')</script>")12}13Hello, <script>alert('you have been pwned')</script>!14import (

Full Screen

Full Screen

ColSpan

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println(html.EscapeString("This is <b>HTML</b>!"))4}5import (6func main() {7 fmt.Println(html.UnescapeString("This is &lt;b&gt;HTML&lt;/b&gt;!"))8}9import (10func main() {11 encoder := html.NewEncoder(os.Stdout)12 encoder.Encode("This is <b>HTML</b>!")13}14import (15func main() {16 tokenizer := html.NewTokenizer(os.Stdin)17 for {18 tt := tokenizer.Next()19 switch tt {20 fmt.Printf("Got text: %q21", tokenizer.Text())22 t := tokenizer.Token()23 fmt.Printf("Got start or end tag: %q24 }25 }26}27import (28func main() {29 tokenizer := html.NewTokenizer(os.Stdin)30 for {31 tt := tokenizer.Next()32 switch tt {33 fmt.Printf("Got text: %q34", tokenizer.Text())35 t := tokenizer.Token()36 fmt.Printf("Got start or end tag: %q37 }38 }39}40import (

Full Screen

Full Screen

ColSpan

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println(html.ColSpan(2))4}5import (6func main() {7 fmt.Println(html.ColSpan(5))8}

Full Screen

Full Screen

ColSpan

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println(html.EscapeString("Hello, world!"))4}5import (6func main() {7 fmt.Println(html.UnescapeString("Hello, world!"))8}9import (10func main() {11 fmt.Println(url.QueryEscape("Hello, world!"))12}13import (14func main() {15 fmt.Println(url.QueryUnescape("Hello%2C+world%21"))16}17import (18func main() {19 if err != nil {20 panic(err)21 }22 fmt.Println(u.Scheme)23 fmt.Println(u.Host)24 fmt.Println(u.Path)25 fmt.Println(u.RawQuery)26 fmt.Println(u.Fragment)27}28import (29func main() {30 if err != nil {31 panic(err)32 }33 fmt.Println(u.Scheme)34 fmt.Println(u.Host)35 fmt.Println(u.Path)36 fmt.Println(u.RawQuery)37 fmt.Println(u.Fragment)38}39import (

Full Screen

Full Screen

ColSpan

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 s := html.EscapeString("Hello, <script>alert('world')</script>")4 fmt.Println(s)5 s = html.UnescapeString(s)6 fmt.Println(s)7 s = html.EscapeString("Hello, world")8 fmt.Println(s)9 s = html.UnescapeString(s)10 fmt.Println(s)11 s = html.EscapeString("Hello, <script>alert('world')</script>")12 fmt.Println(s)13 s = html.UnescapeString(s)14 fmt.Println(s)15 s = html.EscapeString("Hello, world")16 fmt.Println(s)17 s = html.UnescapeString(s)18 fmt.Println(s)19 s = html.EscapeString("Hello, <script>alert('world')</script>")20 fmt.Println(s)21 s = html.UnescapeString(s)22 fmt.Println(s)23 s = html.EscapeString("Hello, world")24 fmt.Println(s)25 s = html.UnescapeString(s)26 fmt.Println(s)27 s = html.EscapeString("Hello, <script>alert('world')</script>")28 fmt.Println(s)29 s = html.UnescapeString(s)30 fmt.Println(s)31 s = html.EscapeString("Hello, world")32 fmt.Println(s)33 s = html.UnescapeString(s)34 fmt.Println(s)35 s = html.EscapeString("Hello, <script>alert('world')</script>")36 fmt.Println(s)37 s = html.UnescapeString(s)38 fmt.Println(s)39 s = html.EscapeString("Hello, world")40 fmt.Println(s)41 s = html.UnescapeString(s)42 fmt.Println(s)43 s = html.EscapeString("Hello, <script>alert('world')</script>")44 fmt.Println(s)45 s = html.UnescapeString(s)46 fmt.Println(s)47 s = html.EscapeString("Hello, world")48 fmt.Println(s)49 s = html.UnescapeString(s)50 fmt.Println(s)51 s = html.EscapeString("Hello, <script>alert('world')</script>")52 fmt.Println(s)53 s = html.UnescapeString(s)54 fmt.Println(s)55 s = html.EscapeString("Hello, world")56 fmt.Println(s)57 s = html.UnescapeString(s)58 fmt.Println(s)59 s = html.EscapeString("Hello, <script>alert('world

Full Screen

Full Screen

ColSpan

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println(html.EscapeString("This is a <b>HTML</b> string!"))4}5import (6func main() {7 fmt.Println(html.UnescapeString("This is a <b>HTML</b> string!"))8}9import (10func main() {11 fmt.Println(html.EscapeString("This is a <b>HTML</b> string!"))12}13import (14func main() {15 fmt.Println(html.UnescapeString("This is a <b>HTML</b> string!"))16}17import (18func main() {19 fmt.Println(html.UnescapeString("This is a <b>HTML</b> string!"))20}21import (22func main() {23 fmt.Println(html.UnescapeString("This is a <b>HTML</b> string!"))24}25import (26func main() {27 fmt.Println(html.UnescapeString("This is a <b>HTML</b> string!"))28}

Full Screen

Full Screen

ColSpan

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println(html.EscapeString("Hello, world"))4}5import (6func main() {7 fmt.Println(html.UnescapeString("Hello, world"))8}9import (10func main() {11 fmt.Println(html.UnescapeString("Hello, world"))12}13import (14func main() {15 fmt.Println(html.UnescapeString("Hello, world"))16}17import (18func main() {19 fmt.Println(html.UnescapeString("Hello, world"))20}21import (22func main() {23 fmt.Println(html.UnescapeString("Hello, world"))24}25import (26func main() {27 fmt.Println(html.UnescapeString("Hello, world"))28}29import (30func main() {31 fmt.Println(html.UnescapeString("Hello, world"))32}33import (34func main() {35 fmt.Println(html.UnescapeString("Hello, world"))36}

Full Screen

Full Screen

ColSpan

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println(html.EscapeString("<script>alert('hello world')</script>"))4}5<script>alert('hello world')</script>6html.EscapeString(s string) string7import (8func main() {9 fmt.Println(html.EscapeString("<script>alert('hello world')</script>"))10}11&lt;script&gt;alert(&#39;hello world&#39;)&lt;/script&gt;12html.UnescapeString(s string) string13import (14func main() {15 fmt.Println(html.UnescapeString("&lt;script&gt;alert(&#39;hello world&#39;)&lt;/script&gt;"))16}17<script>alert('hello world')</script>

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run K6 automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful