read_excle.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Xml;
  4. using UnityEngine;
  5. public class read_excle : MonoBehaviour
  6. {
  7. // Use this for initialization
  8. void Start()
  9. {
  10. path = GetSAPath();
  11. string str = GetWebUrl();
  12. print("GetWebUrl:" + str);
  13. }
  14. // Update is called once per frame
  15. void Update()
  16. {
  17. }
  18. private string path = string.Empty;
  19. public string GetSAPath()
  20. {
  21. /* path = "jar:file://" + Application.dataPath + "!/assets/" + "/demo.xlsx";*/
  22. #if UNITY_EDITOR
  23. path = Application.dataPath + "/StreamingAssets" + "/demo.xlsx";
  24. #elif UNITY_IPHONE
  25. path = Application.dataPath +"/Raw"+"/demo.xlsx";
  26. #elif UNITY_ANDROID
  27. path = "jar:file://" + Application.dataPath + "!/assets/" + "/demo.xlsx";
  28. #endif
  29. /* //安卓平台 加文件名
  30. #if UNITY_ANDROID && !UNITY_EDITOR
  31. path = Application.streamingAssetsPath + "/"
  32. #elif UNITY_IPHONE && !UNITY_EDITOR
  33. path = @"file:///" + Application.streamingAssetsPath + "/";
  34. #elif UNITY_STANDLONE_WIN || UNITY_EDITOR
  35. path = @"file:///" + Application.streamingAssetsPath + "/";
  36. #endif*/
  37. return path;
  38. }
  39. //读取XML文件的方法
  40. public string GetWebUrl()
  41. {
  42. string filepath = path; //Application.StartupPath表示exe文件所在的位置。
  43. bool exists = System.IO.File.Exists(filepath);
  44. print(exists);
  45. if (exists)
  46. {
  47. /* DataSet ds = new DataSet();
  48. ds.ReadXml(filepath);
  49. string strNumber = ds.Tables["webInfo"].Rows[0]["url"].ToString();*/
  50. //return strNumber;
  51. return "000";
  52. }
  53. else
  54. {
  55. return "No url!";
  56. }
  57. }
  58. }