Example #1
0
        private List <Point3d> SplintToExcel(List <Spline> splies, double span)
        {
            List <Point3d> POINTs = new List <Point3d>();

            foreach (Spline sp in splies)
            {
                int    cntNum = sp.NumControlPoints;
                double spLen  = sp.GetDistAtPoint(sp.GetControlPointAt(cntNum - 1));
                double dist   = span;
                while (dist < spLen)
                {
                    POINTs.Add(sp.GetPointAtDist(dist));
                    dist += span;
                }
            }

            int kk = 0;

            string[,] points = new string[POINTs.Count, 2];
            foreach (Point3d item in POINTs)
            {
                points[kk, 0] = item.X.ToString();
                points[kk, 1] = item.Y.ToString();
                kk++;
            }

            string PATH  = Path.Combine(folder, "SplineTest", "SplineData.xlsx");
            EXCEL  Excel = new EXCEL(PATH);

            Excel.Save_To(PATH, "SplineData", 1, 1, points);
            Excel.close();
            return(POINTs);
        }
Example #2
0
        public static string GPSSORT_Main(string dataPath, string savePath, string fileName)
        {
            outPutTxt = "";

            EXCEL Excel = new EXCEL(Path.Combine(dataPath, fileName));

            //string[,] data = ExcelClass.ExcelSaveAndRead.Read(Path.Combine(dataPath, fileName), 1, 1, 1);
            string[,] data      = Excel.GetDataBySheetName(1, 1, Excel.sheets[0]);
            string[,] excelData = TransToExcelFormat(data);

            string SaveName  = "三次元資料.xlsx";
            string sheetName = fileName.Replace(".csv", "");

            sheetName = sheetName.Replace(".CSV", "");
            //ExcelClass.ExcelSaveAndRead.SaveCreat(strPath: Path.Combine(savePath, SaveName), sheetName: sheetName, poRow: 1, poCol: 1, Data: excelData);
            Excel.Save_To(Path.Combine(savePath, SaveName), sheetName, 1, 1, excelData);

            outPutTxt = "處理完成\r\n";
            Excel.close();
            return(outPutTxt);
        }
Example #3
0
        private static void Example()
        {
            /// 要讀取的Excel檔案名稱
            string ExcelName = "sheetData.xlsx";

            /// 要另外儲存的Excel檔案名稱
            string SaveName = "test.xlsx";

            /// 要讀取的Excel檔案路徑
            string fPath = Path.Combine(DeskPath, ExcelName);

            /// 建立Excel 物件
            EXCEL Excel = new EXCEL(fPath);

            /// 取得Excel所有sheet名稱
            List <string> sheets = Excel.sheets;

            /// 讀取第ii個sheet資料,起始位置為(1,1)
            int ii = 0;

            string[,] data = Excel.GetDataBySheetName(1, 1, sheets[ii]);


            /// 讀取所有sheet的資料
            Dictionary <string, string[, ]> AllSheetsData = Excel.GetSheetsData();


            /// 隨意創立要儲存的資料陣列
            string[,] saveData = new string[10, 10];
            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    saveData[i, j] = i.ToString();
                }
            }


            /// 儲存至所開啟之Excel
            Excel.Save("儲存資料至本Excel中", 1, 1, saveData);


            /// 另外儲存的檔案路徑
            string savePath = Path.Combine(DeskPath, SaveName);

            Excel.Save_To(savePath, "儲存資料至其他Excel", 1, 1, saveData);

            Excel.close();



            //////// 顯示資料

            /// 顯示所有Sheets
            ShowSheetsName(sheets);

            /// 顯示讀取Data
            Console.WriteLine("========= 第{0}個sheet : {1} 的Data  ========= ", ii + 1, sheets[ii]);
            ShowData(data);

            /// 顯示所有Sheet資料
            ShowAllExcelData(AllSheetsData);
        }