12
12
using Bluegrams . Application ;
13
13
using BrightIdeasSoftware ;
14
14
using LibHac ;
15
+ using OfficeOpenXml ;
15
16
using FsTitle = LibHac . Title ;
16
17
using Title = NX_Game_Info . Common . Title ;
17
18
using ArrayOfTitle = NX_Game_Info . Common . ArrayOfTitle ;
@@ -387,7 +388,7 @@ private void exportToolStripMenuItem_Click(object sender, EventArgs e)
387
388
{
388
389
SaveFileDialog saveFileDialog = new SaveFileDialog ( ) ;
389
390
saveFileDialog . Title = "Export Titles" ;
390
- saveFileDialog . Filter = "CSV File (*.csv)|*.csv" ;
391
+ saveFileDialog . Filter = "CSV File (*.csv)|*.csv|Excel Workbook (*.xlsx)|*.xlsx " ;
391
392
392
393
Process . log ? . WriteLine ( "\n Export Titles" ) ;
393
394
@@ -462,6 +463,131 @@ private void exportToolStripMenuItem_Click(object sender, EventArgs e)
462
463
MessageBox . Show ( String . Format ( "{0} of {1} titles exported" , index , titles . Count ) , Application . ProductName ) ;
463
464
}
464
465
}
466
+ else if ( filename . EndsWith ( ".xlsx" , StringComparison . OrdinalIgnoreCase ) )
467
+ {
468
+ using ( ExcelPackage excel = new ExcelPackage ( ) )
469
+ {
470
+ progressDialog = ( IProgressDialog ) new ProgressDialog ( ) ;
471
+ progressDialog . StartProgressDialog ( Handle , "Exporting titles" ) ;
472
+
473
+ ExcelWorksheet worksheet = excel . Workbook . Worksheets . Add ( Common . History . Default . Titles . LastOrDefault ( ) . description ?? Application . ProductName ) ;
474
+
475
+ worksheet . Cells [ 1 , 1 , 1 , Title . Properties . Count ( ) ] . LoadFromArrays ( new List < string [ ] > { Title . Properties } ) ;
476
+ worksheet . Cells [ "1:1" ] . Style . Font . Bold = true ;
477
+ worksheet . Cells [ "1:1" ] . Style . Font . Color . SetColor ( Color . White ) ;
478
+ worksheet . Cells [ "1:1" ] . Style . Fill . PatternType = OfficeOpenXml . Style . ExcelFillStyle . Solid ;
479
+ worksheet . Cells [ "1:1" ] . Style . Fill . BackgroundColor . SetColor ( Color . MidnightBlue ) ;
480
+
481
+ uint index = 0 , count = ( uint ) titles . Count ;
482
+
483
+ foreach ( var title in titles )
484
+ {
485
+ if ( progressDialog . HasUserCancelled ( ) )
486
+ {
487
+ break ;
488
+ }
489
+
490
+ progressDialog . SetLine ( 2 , title . titleName , true , IntPtr . Zero ) ;
491
+ progressDialog . SetProgress ( index ++ , count ) ;
492
+
493
+ var data = new List < string [ ] >
494
+ {
495
+ new string [ ] {
496
+ title . titleID ,
497
+ title . baseTitleID ,
498
+ title . titleName ,
499
+ title . displayVersion ,
500
+ title . versionString ,
501
+ title . latestVersionString ,
502
+ title . systemUpdateString ,
503
+ title . systemVersionString ,
504
+ title . applicationVersionString ,
505
+ title . masterkeyString ,
506
+ title . titleKey ,
507
+ title . publisher ,
508
+ title . languagesString ,
509
+ title . filename ,
510
+ title . filesizeString ,
511
+ title . typeString ,
512
+ title . distribution . ToString ( ) ,
513
+ title . structureString ,
514
+ title . signatureString ,
515
+ title . permissionString ,
516
+ title . error ,
517
+ }
518
+ } ;
519
+
520
+ worksheet . Cells [ ( int ) index + 1 , 1 ] . LoadFromArrays ( data ) ;
521
+
522
+ string titleID = title . type == TitleType . AddOnContent ? title . titleID : title . baseTitleID ?? "" ;
523
+
524
+ Process . latestVersions . TryGetValue ( titleID , out uint latestVersion ) ;
525
+ Process . versionList . TryGetValue ( titleID , out uint version ) ;
526
+ Process . titleVersions . TryGetValue ( titleID , out uint titleVersion ) ;
527
+
528
+ if ( latestVersion < version || latestVersion < titleVersion )
529
+ {
530
+ worksheet . Cells [ ( int ) index + 1 , 1 , ( int ) index + 1 , Title . Properties . Count ( ) ] . Style . Fill . PatternType = OfficeOpenXml . Style . ExcelFillStyle . Solid ;
531
+ worksheet . Cells [ ( int ) index + 1 , 1 , ( int ) index + 1 , Title . Properties . Count ( ) ] . Style . Fill . BackgroundColor . SetColor ( title . signature != true ? Color . OldLace : Color . LightYellow ) ;
532
+ }
533
+ else if ( title . signature != true )
534
+ {
535
+ worksheet . Cells [ ( int ) index + 1 , 1 , ( int ) index + 1 , Title . Properties . Count ( ) ] . Style . Fill . PatternType = OfficeOpenXml . Style . ExcelFillStyle . Solid ;
536
+ worksheet . Cells [ ( int ) index + 1 , 1 , ( int ) index + 1 , Title . Properties . Count ( ) ] . Style . Fill . BackgroundColor . SetColor ( Color . WhiteSmoke ) ;
537
+ }
538
+
539
+ if ( title . permission == Title . Permission . Dangerous )
540
+ {
541
+ worksheet . Cells [ ( int ) index + 1 , 1 , ( int ) index + 1 , Title . Properties . Count ( ) ] . Style . Font . Color . SetColor ( Color . DarkRed ) ;
542
+ }
543
+ else if ( title . permission == Title . Permission . Unsafe )
544
+ {
545
+ worksheet . Cells [ ( int ) index + 1 , 1 , ( int ) index + 1 , Title . Properties . Count ( ) ] . Style . Font . Color . SetColor ( Color . Indigo ) ;
546
+ }
547
+ }
548
+
549
+ ExcelRange range = worksheet . Cells [ 1 , 1 , ( int ) count + 1 , Title . Properties . Count ( ) ] ;
550
+ range . Style . Border . Top . Style = OfficeOpenXml . Style . ExcelBorderStyle . Thin ;
551
+ range . Style . Border . Left . Style = OfficeOpenXml . Style . ExcelBorderStyle . Thin ;
552
+ range . Style . Border . Right . Style = OfficeOpenXml . Style . ExcelBorderStyle . Thin ;
553
+ range . Style . Border . Bottom . Style = OfficeOpenXml . Style . ExcelBorderStyle . Thin ;
554
+
555
+ worksheet . Column ( 1 ) . Width = 18 ;
556
+ worksheet . Column ( 2 ) . Width = 18 ;
557
+ worksheet . Column ( 3 ) . AutoFit ( ) ;
558
+ worksheet . Column ( 3 ) . Width = Math . Max ( worksheet . Column ( 3 ) . Width , 30 ) ;
559
+ worksheet . Column ( 4 ) . Width = 16 ;
560
+ worksheet . Column ( 5 ) . Width = 16 ;
561
+ worksheet . Column ( 6 ) . Width = 16 ;
562
+ worksheet . Column ( 7 ) . Width = 16 ;
563
+ worksheet . Column ( 8 ) . Width = 16 ;
564
+ worksheet . Column ( 9 ) . Width = 16 ;
565
+ worksheet . Column ( 10 ) . Width = 16 ;
566
+ worksheet . Column ( 11 ) . AutoFit ( ) ;
567
+ worksheet . Column ( 11 ) . Width = Math . Max ( worksheet . Column ( 11 ) . Width , 36 ) ;
568
+ worksheet . Column ( 12 ) . AutoFit ( ) ;
569
+ worksheet . Column ( 12 ) . Width = Math . Max ( worksheet . Column ( 12 ) . Width , 30 ) ;
570
+ worksheet . Column ( 13 ) . Width = 18 ;
571
+ worksheet . Column ( 14 ) . AutoFit ( ) ;
572
+ worksheet . Column ( 14 ) . Width = Math . Max ( worksheet . Column ( 14 ) . Width , 54 ) ;
573
+ worksheet . Column ( 15 ) . Width = 10 ;
574
+ worksheet . Column ( 16 ) . Width = 10 ;
575
+ worksheet . Column ( 17 ) . Width = 12 ;
576
+ worksheet . Column ( 18 ) . Width = 12 ;
577
+ worksheet . Column ( 19 ) . Width = 10 ;
578
+ worksheet . Column ( 20 ) . Width = 10 ;
579
+ worksheet . Column ( 21 ) . Width = 40 ;
580
+
581
+ excel . SaveAs ( new FileInfo ( filename ) ) ;
582
+
583
+ Process . log ? . WriteLine ( "\n {0} of {1} titles exported" , index , titles . Count ) ;
584
+
585
+ progressDialog . StopProgressDialog ( ) ;
586
+ Activate ( ) ;
587
+
588
+ MessageBox . Show ( String . Format ( "{0} of {1} titles exported" , index , titles . Count ) , Application . ProductName ) ;
589
+ }
590
+ }
465
591
else
466
592
{
467
593
MessageBox . Show ( String . Format ( "This file type is not supported {0}" , Path . GetExtension ( filename ) ) , Application . ProductName ) ;
@@ -483,12 +609,16 @@ private void updateTitleKeysToolStripMenuItem_Click(object sender, EventArgs e)
483
609
484
610
progressDialog . SetLine ( 2 , String . Format ( "Downloading from {0}" , Common . TITLE_KEYS_URI ) , true , IntPtr . Zero ) ;
485
611
612
+ int count = Process . keyset ? . TitleKeys ? . Count ?? 0 ;
613
+
486
614
if ( Process . updateTitleKeys ( ) )
487
615
{
616
+ Process . log ? . WriteLine ( "\n Found {0} updated title keys" , ( Process . keyset ? . TitleKeys ? . Count ?? 0 ) - count ) ;
617
+
488
618
progressDialog . StopProgressDialog ( ) ;
489
619
Activate ( ) ;
490
620
491
- MessageBox . Show ( String . Format ( "Found {0} title keys" , Process . keyset ? . TitleKeys ? . Count ) , Application . ProductName ) ;
621
+ MessageBox . Show ( String . Format ( "Found {0} updated title keys" , ( Process . keyset ? . TitleKeys ? . Count ?? 0 ) - count ) , Application . ProductName ) ;
492
622
}
493
623
else
494
624
{
0 commit comments