excelTest.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.IO;
  4. using org.in2bits.MyXls;
  5. using System;
  6. using System.Collections.Generic;
  7. public class excelTest : MonoBehaviour {
  8. string path;
  9. TestInfo test1;
  10. TestInfo test2;
  11. TestInfo test3;
  12. List<TestInfo> listInfos;
  13. void Start()
  14. {
  15. ExcelMakerManager.CreateExcelMakerManager();
  16. //--测试数据
  17. test1 = new TestInfo();
  18. test1.id = "one";
  19. test1.name = "test1";
  20. test1.num = "x";
  21. test2 = new TestInfo();
  22. test2.id = "two";
  23. test2.name = "test2";
  24. test2.num = "22";
  25. test3 = new TestInfo();
  26. test3.id = "tree";
  27. test3.name = "test3";
  28. test3.num = "333";
  29. listInfos = new List<TestInfo>();
  30. listInfos.Add(test1);
  31. listInfos.Add(test2);
  32. listInfos.Add(test3);
  33. }
  34. void OnGUI()
  35. {
  36. if (GUI.Button(new Rect(100, 0, 100, 100), "aa"))
  37. {
  38. PrintExcel();
  39. }
  40. }
  41. /// <summary>
  42. /// 测试存储--文件存储位置Assets/Prints文件夹内
  43. /// </summary>
  44. public void PrintExcel()
  45. {
  46. Debug.Log("-- 存储Excel");
  47. if (!Directory.Exists(Application.dataPath + "/Prints"))
  48. {
  49. Directory.CreateDirectory(Application.dataPath + "/Prints");
  50. }
  51. path = Application.dataPath + "/Prints/Excel_"
  52. + System.DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss") + ".xls";
  53. ExcelMakerManager.eInstance.ExcelMaker(path, listInfos);
  54. }
  55. }