コード例 #1
0
        internal void SetUp(int id, string tableName, string displayName, Cell topLeft, Cell bottomRight)
        {
            _id = id;
            _tableName = tableName.Replace(' ', '_');
            _tl = new Point(topLeft.ColumnIndex, topLeft.RowIndex);
            _br = new Point(bottomRight.ColumnIndex, bottomRight.RowIndex);
            DisplayName = displayName.Replace(' ','_');

            List<TableColumn> tableColumns = new List<TableColumn>();
            int cnt = 1;
            for (int i = (int)_tl.X; i <= (int)_br.X; i++)
            {
                TableColumn col = CreateElement<TableColumn>();
                col.ID = cnt;
                col.Name = "Column" + cnt;
                tableColumns.Add(col);
                cnt++;
            }
            TableColumns = tableColumns.ToArray();
        }
コード例 #2
0
        static public void GenerateXLS(string fileName, List<RoadMap> roadmaps, double conso, double gasCost)
        {

            Total total = new Total();
            SpreadsheetDocument doc = new SpreadsheetDocument();
            doc.ApplicationName = "PlanMyWay";
            doc.Creator = "SuperBen";
            doc.Company = "PlanMyWay & Co.";


            doc.Workbook.Sheets.FirstOrDefault().Sheet.Rows[0].Cells[1].SetValue("Consommation moyenne du véhicule");
            doc.Workbook.Sheets.FirstOrDefault().Sheet.Rows[1].Cells[1].SetValue("Prix du carburant");
            consoDefinition = doc.Workbook.Sheets.FirstOrDefault().Sheet.Rows[0].Cells[3];
            gasCostDefinition = doc.Workbook.Sheets.FirstOrDefault().Sheet.Rows[1].Cells[3];
            consoDefinition.SetValue(new Decimal(conso));
            gasCostDefinition.SetValue(new Decimal(gasCost));

            for (int i = 0; i< roadmaps.Count; i++)
            {
                if (i > 0)
                {
                    total.Distance += "+";
                    total.Conso += "+";
                    total.CoutTotal += "+";
                }
                total += SpreadSheetRoadmapGenerator.AddTableXLS(ref doc, roadmaps[i]);

            }
            SpreadSheetRoadmapGenerator.AddTotalXLS(ref doc, total);

            using (IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication())
            using (Stream writeFile = new IsolatedStorageFileStream(fileName, FileMode.Create, file))
            using (IStreamProvider storage = new ZipStreamProvider(writeFile))
            {
                doc.Save(storage);
            }
        }
コード例 #3
0
 public TablePart AddTable(string tableName, string displayName, Cell topLeft, Cell bottomRight)
 {
     string partName = string.Format("/xl/tables/table{0}.xml", Tables.Count() + 1);
     //string partName = string.Format("/xl/tables/table_{0}_{1}.xml", SheetID, Tables.Count() + 1);
     TablePart table = Package.CreatePart<TablePart>(partName);
     table.SetUp(_tables.Count + 1, tableName, displayName, topLeft, bottomRight);
     AddRelationship(table);
     _tables.Add(table);
     return table;
 }