forked from monkey256/ExcelExport
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Security.Cryptography; | ||
using System.Text; | ||
using System.Text.RegularExpressions; | ||
using System.Threading; | ||
|
||
namespace tablegen2.logic | ||
{ | ||
public static class TableExcelExportCsEx | ||
{ | ||
public static void ExportExcelFile(TableExcelData data, string filePath, string fileName) | ||
{ | ||
var csString = new StringBuilder(); | ||
csString.AppendTemplate(fileName); | ||
|
||
File.WriteAllBytes(filePath, Encoding.UTF8.GetBytes(csString.ToString())); | ||
} | ||
|
||
private static void AppendTemplate(this StringBuilder sb, string className) | ||
{ | ||
sb.AppendLine(@"using System.Collections.Generic;"); | ||
sb.AppendLine(@"using UnityEngine;"); | ||
sb.AppendLine(@""); | ||
sb.AppendLine(@"namespace Feamber.Data"); | ||
sb.AppendLine(@"{"); | ||
sb.AppendLine($" public sealed partial class { className } : IBaseData"); | ||
sb.AppendLine(@" {"); | ||
sb.AppendLine($" public void OnValidate()"); | ||
sb.AppendLine(@" {"); | ||
sb.AppendLine(@" Debug.Assert(Index > 0, $""{ nameof(Index)}{ Index} (excel-id) must greater than 0"");"); | ||
sb.AppendLine(@" }"); | ||
sb.AppendLine(@" }"); | ||
sb.AppendLine(@""); | ||
sb.AppendLine(@" public static partial class DataListExtensioMethods"); | ||
sb.AppendLine(@" {"); | ||
sb.AppendLine($" public static void Demo(this DataList<{ className }> dataList)"); | ||
sb.AppendLine(@" {"); | ||
sb.AppendLine(@" }"); | ||
sb.AppendLine(@" }"); | ||
sb.AppendLine(@"}"); | ||
sb.AppendLine(@""); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters