TestLink online use case Excel xml conversion

Git repository Address: [ TestLink-SpringBoot use EasyExcel and BootStrap FileInput upload Excel ]

Item Function

TestLink online use case Excel converts xml
will meet the Excel template test use cases, converted to xml, import for TestLink use case management.

Instructions

  • 1, write test cases
  • 2, open the project http: // localhost: 8080, browse to the file, click the Upload icon on the icon
  • 3. Select the sheet name
  • 4. Click on the point I convert button, the background to handle the data, click the OK button to download the xml files generated.
  • 5, in the tesklink, introducing the resulting xml use cases.

Technical Framework

SpringBoot use EasyExcel and BootStrap FileInput upload Excel

rear end
  • springboot
  • springmvc
  • easyexcel
  • jdom2
front end
  • jquery v1.12.4
  • Bootstrap v4.3.1
  • bootstrap-fileinput v5.0.1
  • jquery-confirm v3.3.0

Encountered pit

  • 1, fileinput plug-in does not appear Chinese

According to the official website Demo, pay attention to the order of introduction of css and js, and add a "language: 'zh'" configuration item, or display a page in English.

HTML:
    <input id="excel" name="file" class="file" type="file" placeholder="选择一个Excel文件">
JS:
    $("#excel").fileinput({
        language: 'zh',
        maxFileCount: 1,
        required: true,
        uploadAsync: false,
        allowedFileExtensions : ['xls','xlsx'],//允许的文件类型
        enctype: 'multipart/form-data',
        uploadUrl: server + '/testLink/uploadExcel',
        showRemove:false,
        showPreview : true, //是否显示预览
        validateInitialCount:true,
        overwriteInitial: true//是否在上传下一个文件的时候覆盖前一个
    });

The final blog post wrote: Remove class = "file" can be.

  • 2, using the 2003 version of the EasyExcel import xls file, an error

According to error prompt, in MultipartFile.getInputStream () outer packaging of BufferedInputStream, to solve the problem

EasyExcelFactory.getReader(new BufferedInputStream(excelFile.getInputStream())...
  • 3, fileinput plug-in does not display the icon, in fact, does not display icons for bootstrap

bootstrap4 not supported by default icon, copy bootstrap3 icon fonts to the project, and add fonts.css, document preparation to complete.
Due to the use of SpringBoot2.x, maven will automatically ignore font files, modify pom.xml as follows, normal icon display.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-resources-plugin</artifactId>
    <configuration>
        <nonFilteredFileExtensions>
            <nonFilteredFileExtension>eot</nonFilteredFileExtension>
            <nonFilteredFileExtension>svg</nonFilteredFileExtension>
            <nonFilteredFileExtension>ttf</nonFilteredFileExtension>
            <nonFilteredFileExtension>woff</nonFilteredFileExtension>
            <nonFilteredFileExtension>woff2</nonFilteredFileExtension>
        </nonFilteredFileExtensions>
    </configuration>
</plugin>
  • 4, xml file download

ajax can not download the file, the file name is returned as long as the background, foreground submit files downloaded via window.location.href = url form or forms.

var $eleForm = $("<form method='get'></form>");

$eleForm.attr("action",url);

$(document.body).append($eleForm);

//提交表单,实现下载
$eleForm.submit();

Guess you like

Origin www.cnblogs.com/Candies/p/11130712.html