File tree Expand file tree Collapse file tree 3 files changed +18
-58
lines changed Expand file tree Collapse file tree 3 files changed +18
-58
lines changed Original file line number Diff line number Diff line change 1+ use excel_gen:: excel:: { WorkbookDto , WorksheetDto } ;
2+
13mod common;
24
35#[ test]
46fn should_create_excel_file ( ) {
5- let file = common:: create_avro_from_json ( include_str ! ( "./input/without_format.json" ) ) ;
6- println ! ( "test {:?}" , file)
7- }
7+ let workbook = WorkbookDto :: builder ( )
8+ . worksheets ( vec ! [
9+ WorksheetDto :: builder( )
10+ . name( "Feuille 1" )
11+ . autofit( true )
12+ . build( ) ,
13+ WorksheetDto :: builder( ) . autofit( false ) . build( ) ,
14+ ] )
15+ . build ( ) ;
816
9- #[ test]
10- fn should_create_excel_file_with_format ( ) {
11- // TODO
17+ common:: create_avro_from_workbook ( "excel_01" , workbook) ;
1218}
Original file line number Diff line number Diff line change 11use apache_avro:: Writer ;
22use excel_gen:: { excel:: WorkbookDto , parser:: avro:: AvroParser } ;
3+ use std:: fs:: File ;
34
4- #[ allow( dead_code) ]
5- pub fn create_avro_from_json ( json : & str ) -> Vec < u8 > {
5+ pub fn create_avro_from_workbook ( name : & str , workbook : WorkbookDto ) {
66 let avro_parser = AvroParser :: new ( ) . unwrap ( ) ;
77 let schema = avro_parser. get_schema ( ) ;
88
9- let workbook_dto: WorkbookDto = serde_json:: from_str ( json) . unwrap ( ) ;
9+ let file = File :: create ( format ! ( "tests/output/{}.avro" , name) ) . unwrap ( ) ;
10+ let mut writer = Writer :: new ( schema, file) ;
1011
11- let mut writer = Writer :: new ( schema, Vec :: new ( ) ) ;
12- writer. append_ser ( workbook_dto) . unwrap ( ) ;
12+ writer. append_ser ( workbook) . unwrap ( ) ;
1313
14- writer. into_inner ( ) . unwrap ( )
14+ writer. flush ( ) . unwrap ( ) ;
1515}
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments