public static void Main() { //Source directory string sourceDir = RunExamples.Get_SourceDirectory() + "SampleXmlData\\"; // Load XLSX file containing data from XML file Workbook workbook = new Workbook(sourceDir + "XML Data.xlsx"); // Access the first worksheet Worksheet ws = workbook.Worksheets[0]; // Access ListObject from the first sheet Aspose.Cells.Tables.ListObject listObject = ws.ListObjects[0]; // Get the url of the list object's xml map data binding string url = listObject.XmlMap.DataBinding.Url; // Display XML file name Console.WriteLine(url); Console.WriteLine("GetXMLPathFromListObjectTable executed successfully.\r\n"); }
private void SaveData() { string dataDir = @"C:\Users\Artur\Desktop\GGGGWP"; bool IsExists = System.IO.Directory.Exists(dataDir); if (!IsExists) { System.IO.Directory.CreateDirectory(dataDir); } Workbook wb = new Workbook(); Worksheet sheet = wb.Worksheets[0]; Cells cells = sheet.Cells; Cell cell = cells["A1"]; cell.PutValue("главное окно"); if (_main_grid != null) { int g = 2; foreach (var bllist in _main_grid) { cell = cells["A" + g.ToString()]; cell.PutValue(bllist.NameObjekt.ToString()); cell = cells["B" + g.ToString()]; cell.PutValue(bllist.ShemeCheck.ToString()); cell = cells["C" + g.ToString()]; cell.PutValue(bllist.TimeStart.ToString()); cell = cells["D" + g.ToString()]; cell.PutValue(bllist.TimeStop.ToString()); g++; } } else { MessageBox.Show("Нету данных"); return; } cell = cells["J1"]; cell.PutValue("1_Обьект"); int i = 2; foreach (var bllist in data_Grid_1s) { cell = cells["J" + i.ToString()]; cell.PutValue(bllist.CreationDatef.ToString()); cell = cells["K" + i.ToString()]; cell.PutValue(bllist.UA.ToString()); cell = cells["L" + i.ToString()]; cell.PutValue(bllist.IA.ToString()); cell = cells["M" + i.ToString()]; cell.PutValue(bllist.PA.ToString()); cell = cells["N" + i.ToString()]; cell.PutValue(bllist.QA.ToString()); cell = cells["O" + i.ToString()]; cell.PutValue(bllist.Freq.ToString()); cell = cells["P" + i.ToString()]; cell.PutValue(bllist.sigmaUy.ToString()); i++; } i = 2; cell = cells["Q1"]; cell.PutValue("2_Обьект"); foreach (var bllist in data_Grid_2s) { cell = cells["Q" + i.ToString()]; cell.PutValue(bllist.CreationDates.ToString()); cell = cells["R" + i.ToString()]; cell.PutValue(bllist.UAB.ToString()); cell = cells["S" + i.ToString()]; cell.PutValue(bllist.UBC.ToString()); cell = cells["T" + i.ToString()]; cell.PutValue(bllist.UCA.ToString()); cell = cells["U" + i.ToString()]; cell.PutValue(bllist.IAB.ToString()); cell = cells["V" + i.ToString()]; cell.PutValue(bllist.IBC.ToString()); cell = cells["W" + i.ToString()]; cell.PutValue(bllist.ICA.ToString()); cell = cells["X" + i.ToString()]; cell.PutValue(bllist.IA.ToString()); cell = cells["Y" + i.ToString()]; cell.PutValue(bllist.IB.ToString()); cell = cells["Z" + i.ToString()]; cell.PutValue(bllist.IC.ToString()); cell = cells["AA" + i.ToString()]; cell.PutValue(bllist.P0.ToString()); cell = cells["AB" + i.ToString()]; cell.PutValue(bllist.PP.ToString()); cell = cells["AC" + i.ToString()]; cell.PutValue(bllist.Q0.ToString()); cell = cells["AD" + i.ToString()]; cell.PutValue(bllist.QP.ToString()); cell = cells["AE" + i.ToString()]; cell.PutValue(bllist.S0.ToString()); cell = cells["AF" + i.ToString()]; cell.PutValue(bllist.SP.ToString()); cell = cells["AG" + i.ToString()]; cell.PutValue(bllist.U0.ToString()); cell = cells["AH" + i.ToString()]; cell.PutValue(bllist.UP.ToString()); cell = cells["AI" + i.ToString()]; cell.PutValue(bllist.I0.ToString()); cell = cells["AJ" + i.ToString()]; cell.PutValue(bllist.IP.ToString()); cell = cells["AK" + i.ToString()]; cell.PutValue(bllist.K0.ToString()); cell = cells["AL" + i.ToString()]; cell.PutValue(bllist.Freq.ToString()); cell = cells["AM" + i.ToString()]; cell.PutValue(bllist.sigmaUy.ToString()); cell = cells["AN" + i.ToString()]; cell.PutValue(bllist.sigmaUyAB.ToString()); cell = cells["AO" + i.ToString()]; cell.PutValue(bllist.sigmaUyBC.ToString()); cell = cells["AP" + i.ToString()]; cell.PutValue(bllist.sigmaUyCA.ToString()); i++; } Aspose.Cells.Tables.ListObject listObject = sheet.ListObjects[sheet.ListObjects.Add("A1", "F2", true)]; listObject.TableStyleType = Aspose.Cells.Tables.TableStyleType.TableStyleMedium10; wb.Save(dataDir + "output.xlsx"); MessageBox.Show("Записано"); }
public static void Main(string[] args) { // The path to the documents directory. string dataDir = Path.GetFullPath("../../../Data/"); // Create directory if it is not already present. bool IsExists = System.IO.Directory.Exists(dataDir); if (!IsExists) { System.IO.Directory.CreateDirectory(dataDir); } //Create a workbook. Workbook workbook = new Workbook(); //Obtaining the reference of the default(first) worksheet Worksheet sheet = workbook.Worksheets[0]; //Obtaining Worksheet's cells collection Cells cells = sheet.Cells; //Setting the value to the cells Aspose.Cells.Cell cell = cells["A1"]; cell.PutValue("Employee"); cell = cells["B1"]; cell.PutValue("Quarter"); cell = cells["C1"]; cell.PutValue("Product"); cell = cells["D1"]; cell.PutValue("Continent"); cell = cells["E1"]; cell.PutValue("Country"); cell = cells["F1"]; cell.PutValue("Sale"); cell = cells["A2"]; cell.PutValue("David"); cell = cells["A3"]; cell.PutValue("David"); cell = cells["A4"]; cell.PutValue("David"); cell = cells["A5"]; cell.PutValue("David"); cell = cells["A6"]; cell.PutValue("James"); cell = cells["A7"]; cell.PutValue("James"); cell = cells["A8"]; cell.PutValue("James"); cell = cells["A9"]; cell.PutValue("James"); cell = cells["A10"]; cell.PutValue("James"); cell = cells["A11"]; cell.PutValue("Miya"); cell = cells["A12"]; cell.PutValue("Miya"); cell = cells["A13"]; cell.PutValue("Miya"); cell = cells["A14"]; cell.PutValue("Miya"); cell = cells["A15"]; cell.PutValue("Miya"); cell = cells["B2"]; cell.PutValue(1); cell = cells["B3"]; cell.PutValue(2); cell = cells["B4"]; cell.PutValue(3); cell = cells["B5"]; cell.PutValue(4); cell = cells["B6"]; cell.PutValue(1); cell = cells["B7"]; cell.PutValue(2); cell = cells["B8"]; cell.PutValue(3); cell = cells["B9"]; cell.PutValue(4); cell = cells["B10"]; cell.PutValue(4); cell = cells["B11"]; cell.PutValue(1); cell = cells["B12"]; cell.PutValue(1); cell = cells["B13"]; cell.PutValue(2); cell = cells["B14"]; cell.PutValue(2); cell = cells["B15"]; cell.PutValue(2); cell = cells["C2"]; cell.PutValue("Maxilaku"); cell = cells["C3"]; cell.PutValue("Maxilaku"); cell = cells["C4"]; cell.PutValue("Chai"); cell = cells["C5"]; cell.PutValue("Maxilaku"); cell = cells["C6"]; cell.PutValue("Chang"); cell = cells["C7"]; cell.PutValue("Chang"); cell = cells["C8"]; cell.PutValue("Chang"); cell = cells["C9"]; cell.PutValue("Chang"); cell = cells["C10"]; cell.PutValue("Chang"); cell = cells["C11"]; cell.PutValue("Geitost"); cell = cells["C12"]; cell.PutValue("Chai"); cell = cells["C13"]; cell.PutValue("Geitost"); cell = cells["C14"]; cell.PutValue("Geitost"); cell = cells["C15"]; cell.PutValue("Geitost"); cell = cells["D2"]; cell.PutValue("Asia"); cell = cells["D3"]; cell.PutValue("Asia"); cell = cells["D4"]; cell.PutValue("Asia"); cell = cells["D5"]; cell.PutValue("Asia"); cell = cells["D6"]; cell.PutValue("Europe"); cell = cells["D7"]; cell.PutValue("Europe"); cell = cells["D8"]; cell.PutValue("Europe"); cell = cells["D9"]; cell.PutValue("Europe"); cell = cells["D10"]; cell.PutValue("Europe"); cell = cells["D11"]; cell.PutValue("America"); cell = cells["D12"]; cell.PutValue("America"); cell = cells["D13"]; cell.PutValue("America"); cell = cells["D14"]; cell.PutValue("America"); cell = cells["D15"]; cell.PutValue("America"); cell = cells["E2"]; cell.PutValue("China"); cell = cells["E3"]; cell.PutValue("India"); cell = cells["E4"]; cell.PutValue("Korea"); cell = cells["E5"]; cell.PutValue("India"); cell = cells["E6"]; cell.PutValue("France"); cell = cells["E7"]; cell.PutValue("France"); cell = cells["E8"]; cell.PutValue("Germany"); cell = cells["E9"]; cell.PutValue("Italy"); cell = cells["E10"]; cell.PutValue("France"); cell = cells["E11"]; cell.PutValue("U.S."); cell = cells["E12"]; cell.PutValue("U.S."); cell = cells["E13"]; cell.PutValue("Brazil"); cell = cells["E14"]; cell.PutValue("U.S."); cell = cells["E15"]; cell.PutValue("U.S."); cell = cells["F2"]; cell.PutValue(2000); cell = cells["F3"]; cell.PutValue(500); cell = cells["F4"]; cell.PutValue(1200); cell = cells["F5"]; cell.PutValue(1500); cell = cells["F6"]; cell.PutValue(500); cell = cells["F7"]; cell.PutValue(1500); cell = cells["F8"]; cell.PutValue(800); cell = cells["F9"]; cell.PutValue(900); cell = cells["F10"]; cell.PutValue(500); cell = cells["F11"]; cell.PutValue(1600); cell = cells["F12"]; cell.PutValue(600); cell = cells["F13"]; cell.PutValue(2000); cell = cells["F14"]; cell.PutValue(500); cell = cells["F15"]; cell.PutValue(900); //Adding a new List Object to the worksheet Aspose.Cells.Tables.ListObject listObject = sheet.ListObjects[sheet.ListObjects.Add("A1", "F15", true)]; //Adding Default Style to the table listObject.TableStyleType = Aspose.Cells.Tables.TableStyleType.TableStyleMedium10; //Show Total listObject.ShowTotals = true; //Set the Quarter field's calculation type listObject.ListColumns[1].TotalsCalculation = Aspose.Cells.Tables.TotalsCalculation.Count; //Saving the Excel file workbook.Save(dataDir + "List_Object.xlsx"); }