コード例 #1
0
        public override void WriteHeaderLineToClosedXmlWorkSheet(ClosedXML.Excel.IXLWorksheet worksheet, int row)
        {
            char cell = 'A';

            string cellKey;

            cellKey = GetCellKey(row, cell++);
            worksheet.Cell(cellKey).Value = "MapItemCategory";

            cellKey = GetCellKey(row, cell++);
            worksheet.Cell(cellKey).Value = "Identifiers";

            cellKey = GetCellKey(row, cell++);
            worksheet.Cell(cellKey).Value = "Name";

            cellKey = GetCellKey(row, cell++);
            worksheet.Cell(cellKey).Value = "AddressType";

            cellKey = GetCellKey(row, cell++);
            worksheet.Cell(cellKey).Value = "Address";

            cellKey = GetCellKey(row, cell++);
            worksheet.Cell(cellKey).Value = "SpatialLocation";

            cellKey = GetCellKey(row, cell++);
            worksheet.Cell(cellKey).Value = "Url";
        }
コード例 #2
0
        bool SaveSequence(ClosedXML.Excel.IXLWorksheet sheet, int row)
        {
            sheet.Cell(row, 1).Value = TempPokemon.No;
            sheet.Cell(row, 2).Value = TempPokemon.Name;
            sheet.Cell(row, 3).Value = TempPokemon.Character;
            sheet.Cell(row, 4).Value = TempPokemon.Item;
            sheet.Cell(row, 5).Value = TempPokemon.Ability;

            for (int i = 0; i < 6; i++)
            {
                sheet.Cell(row, i + 10).Value = TempPokemon.EffortValue[i];
                sheet.Cell(row, i + 16).Value = TempPokemon.IndividualValue[i];
                sheet.Cell(row, i + 22).Value = TempPokemon.Statistics[i];
            }
            for (int i = 0; i < 4; i++)
            {
                try
                {
                    sheet.Cell(row, i + 6).Value = TempPokemon.Weapon[i];
                }
                catch (IndexOutOfRangeException)
                {
                    System.Windows.Forms.MessageBox.Show("ワザの入力が正しくありません");
                    for (int j = 1; j <= 27; j++)
                    {
                        sheet.Cell(row, j).Value = "";
                    }
                    return(false);
                }
            }
            return(true);
        }
コード例 #3
0
            public override void WriteDataItemToClosedXmlWorkSheet(ClosedXML.Excel.IXLWorksheet worksheet, MSBuildLogsExtended.DataSourceEntities.BuildLog.Default dataItem, int row)
            {
                char cell = 'A';

                string cellKey;

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.Build_1_Name;

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.Id;

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.Solution_1Id;

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.Solution_1_Name;

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.BuildEventCode_1_Name;

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.BuildId;

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.BuildEventCodeId;

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.Message;

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.EventTime;
            }
コード例 #4
0
ファイル: XLSXReport.cs プロジェクト: H0K5/SharesMapper
        /// <summary>
        /// Write ACL evolution into worksheet.
        /// </summary>
        /// <param name="worksheet"></param>
        /// <param name="hostname"></param>
        /// <param name="shareName"></param>
        /// <param name="remark"></param>
        /// <param name="level"></param>
        /// <param name="ACLEvolution"></param>
        /// <param name="row">Row number to start from</param>
        /// <param name="lastScan">List of ACE_ID of the first scan</param>
        /// <returns></returns>
        static int InsertACLEvolution(ClosedXML.Excel.IXLWorksheet worksheet, string hostname, string shareName, string remark, int level, Dictionary <DateTime, Dictionary <string, Dictionary <string, string> > > ACLEvolution, int row, List <string> lastScan = null)
        {
            int           count = 1;
            List <string> nextScan;

            foreach (Dictionary <string, Dictionary <string, string> > acl in ACLEvolution.Values)
            {
                if (ACLEvolution.Count > count)
                {
                    nextScan = ACLEvolution[ACLEvolution.Keys.ToList()[count]].Keys.ToList();
                    count++;
                }
                else
                {
                    nextScan = null;
                }
                row = InsertACL(
                    worksheet,
                    hostname,
                    shareName,
                    remark,
                    level,
                    acl,
                    row,
                    lastScan,
                    nextScan
                    );
                lastScan = acl.Keys.ToList();
            }

            return(row);
        }
コード例 #5
0
        public override void WriteDataItemToClosedXmlWorkSheet(ClosedXML.Excel.IXLWorksheet worksheet, Elmah.DataSourceEntities.MapItem dataItem, int row)
        {
            char cell = 'A';

            string cellKey;

            cellKey = GetCellKey(row, cell++);
            worksheet.Cell(cellKey).Value = dataItem.MapItemCategory;

            cellKey = GetCellKey(row, cell++);
            worksheet.Cell(cellKey).Value = dataItem.Identifiers;

            cellKey = GetCellKey(row, cell++);
            worksheet.Cell(cellKey).Value = dataItem.Name;

            cellKey = GetCellKey(row, cell++);
            worksheet.Cell(cellKey).Value = dataItem.AddressType;

            cellKey = GetCellKey(row, cell++);
            worksheet.Cell(cellKey).Value = dataItem.Address;

            cellKey = GetCellKey(row, cell++);
            worksheet.Cell(cellKey).Value = Framework.Helpers.GeoHelperSinglton.Instance.GeographyToGmlV3(dataItem.SpatialLocation);

            cellKey = GetCellKey(row, cell++);
            worksheet.Cell(cellKey).Value = dataItem.Url;
        }
コード例 #6
0
            public override void WriteDataItemToClosedXmlWorkSheet(ClosedXML.Excel.IXLWorksheet worksheet, MSBuildExtensionPack.DataSourceEntities.BuildLog.DefaultGroupedDataView dataItem, int row)
            {
                char cell = 'A';

                string cellKey;

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.BuildId;

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.BuildEventCodeId;

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.CountPerFK;

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.Name;

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.Solution_1Id;

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.Organization_1Id;

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.Organization_2Id;
            }
コード例 #7
0
            public override void WriteHeaderLineToClosedXmlWorkSheet(ClosedXML.Excel.IXLWorksheet worksheet, int row)
            {
                char cell = 'A';

                string cellKey;

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "BuildId";

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "BuildEventCodeId";

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "CountPerFK";

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "Name";

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "Solution_1Id";

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "Organization_1Id";

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "Organization_2Id";
            }
コード例 #8
0
        public static void ClosedXmlReader(string inFile, string outFile)
        {
            var workbook = new ClosedXML.Excel.XLWorkbook(inFile);

            ClosedXML.Excel.IXLWorksheet sheet = workbook.Worksheets.Worksheet(1);
            var sb      = new StringBuilder();
            var rows    = sheet.LastRowUsed().RangeAddress.FirstAddress.RowNumber;
            var columns = sheet.LastColumnUsed().RangeAddress.FirstAddress.ColumnNumber;

            foreach (var row in sheet.Rows())
            {
                foreach (var cell in row.Cells())
                {
                    string s = cell.GetString();
                    if (s.Contains('\n'))
                    {
                        sb.Append("\"" + s + "\"\t");
                    }
                    else
                    {
                        sb.Append(s + "\t");
                    }
                }
                sb.Remove(sb.Length - 1, 1);
                sb.Append("\n");
            }
            File.WriteAllText(outFile, sb.ToString());
        }
コード例 #9
0
 /// <summary>
 /// 選擇檔案後觸發的上傳檔案事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void rauXLSXUpload_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e)
 {
     if (rauXLSXUpload.UploadedFiles.Count > 0) // 判斷是否有上傳檔案
     {
         List <string> lsTempPath = new List <string>();
         foreach (Telerik.Web.UI.UploadedFile postedFile in rauXLSXUpload.UploadedFiles) // 巡覽上傳的所有檔案
         {
             if (postedFile != null)
             {
                 string extensionName = System.IO.Path.GetExtension(postedFile.FileName);
                 if (extensionName.Equals(".xls") || extensionName.Equals(".xlsx")) // 沒有
                 {
                     using (FileStream filestream = postedFile.InputStream as FileStream)
                         using (ClosedXML.Excel.XLWorkbook wb = new ClosedXML.Excel.XLWorkbook(filestream))
                         {
                             lsTempPath.Add(filestream.Name);
                             ClosedXML.Excel.IXLWorksheet sheet = null;
                             try
                             {
                                 sheet = wb.Worksheets.Worksheet("Sheet1");
                             }
                             catch
                             {
                                 sheet = wb.Worksheets.Worksheet("工作表1");
                             }
                             if (sheet == null) // 找不到工作表就離開
                             {
                                 break;
                             }
                             ktxtTABLE_NAME.Text = sheet.Cell(1, 1).GetString(); // 表格名稱
                             int       rowIndex = 3;
                             DataTable dtSource = getDefalutTable();             // 每次都當最新的
                             while (!sheet.Cell(rowIndex, 2).IsEmpty())          // 欄位名稱是空的
                             {
                                 DataRow ndr = dtSource.NewRow();
                                 ndr["PK"]            = sheet.Cell(rowIndex, 1).GetString().ToUpper().Trim(); // 鍵值
                                 ndr["COLUMN_NAME"]   = sheet.Cell(rowIndex, 2).GetString().ToUpper().Trim(); // 欄位名稱
                                 ndr["DATA_TYPE"]     = sheet.Cell(rowIndex, 3).GetString().ToUpper().Trim(); // 欄位類型
                                 ndr["ALLOW_NULL"]    = sheet.Cell(rowIndex, 4).GetString().ToUpper().Trim(); // 允許NULL
                                 ndr["DEFAULT_VALUE"] = "";                                                   // 預設值
                                 ndr["COLUMN_DESC"]   = sheet.Cell(rowIndex, 5).GetString().ToUpper().Trim(); // 說明
                                 dtSource.Rows.Add(ndr);
                                 rowIndex++;
                             }
                             ViewState["gvColumns"] = dtSource;
                             gvColumns.DataSource   = ViewState["gvColumns"];
                             gvColumns.DataBind();
                         }
                 }
             }
         }
         // 刪除暫存檔
         foreach (string _tmpPath in lsTempPath)
         {
             File.Delete(_tmpPath);
         }
     }
 }
コード例 #10
0
        public static void ClosedXmlWriter(string inFile, string outFile)
        {
            var workbook = new ClosedXML.Excel.XLWorkbook();

            ClosedXML.Excel.IXLWorksheet sheet = workbook.Worksheets.Add("Sheet1");
            using (var sr = new StreamReader(File.OpenRead(inFile)))
            {
                int    r    = 1;
                string line = "";
                string s;
                bool   ifInner = false;
                while ((s = sr.ReadLine()) != null)
                {
                    if (ifInner)
                    {
                        line += "\n" + s;
                        if (s.Contains("\"\t"))
                        {
                            ifInner = false;
                        }
                        else
                        {
                            continue;
                        }
                    }
                    else
                    {
                        line = s;
                    }

                    int pos;
                    if ((pos = s.LastIndexOf('\t')) > -1 && pos != s.Length - 1)
                    {
                        if (s[pos + 1] == '"' && s[s.Length - 1] != '"')
                        {
                            ifInner = true;
                            continue;
                        }
                    }

                    var      row     = sheet.Row(r);
                    string[] columns = line.Split('\t');
                    for (var c = 0; c < columns.Length; c++)
                    {
                        if (double.TryParse(columns[c], out double value))
                        {
                            row.Cell(c + 1).Value = value;
                        }
                        else
                        {
                            row.Cell(c + 1).Value = columns[c].Trim('"');
                        }
                    }
                    r++;
                }
            }
            workbook.SaveAs(outFile);
        }
コード例 #11
0
        public override void WriteHeaderLineToClosedXmlWorkSheet(ClosedXML.Excel.IXLWorksheet worksheet, int row)
        {
            char cell = 'A';

            string cellKey;

            cellKey = GetCellKey(row, cell++);
            worksheet.Cell(cellKey).Value = "Host";
        }
コード例 #12
0
            public override void WriteHeaderLineToClosedXmlWorkSheet(ClosedXML.Excel.IXLWorksheet worksheet, int row)
            {
                char cell = 'A';

                string cellKey;

                cellKey = GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "ElmahApplication_Name";

                cellKey = GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "ErrorId";

                cellKey = GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "ElmahHost_Name";

                cellKey = GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "ElmahSource_Name";

                cellKey = GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "ElmahStatusCode_Name";

                cellKey = GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "ElmahType_Name";

                cellKey = GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "ElmahUser_Name";

                cellKey = GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "Application";

                cellKey = GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "Host";

                cellKey = GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "Type";

                cellKey = GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "Source";

                cellKey = GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "Message";

                cellKey = GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "User";

                cellKey = GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "StatusCode";

                cellKey = GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "TimeUtc";

                cellKey = GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "Sequence";

                cellKey = GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "AllXml";
            }
コード例 #13
0
        public override void WriteDataItemToClosedXmlWorkSheet(ClosedXML.Excel.IXLWorksheet worksheet, Elmah.DataSourceEntities.ElmahHost dataItem, int row)
        {
            char cell = 'A';

            string cellKey;

            cellKey = GetCellKey(row, cell++);
            worksheet.Cell(cellKey).Value = dataItem.Host;
        }
コード例 #14
0
            public override void WriteDataItemToClosedXmlWorkSheet(ClosedXML.Excel.IXLWorksheet worksheet, Elmah.DataSourceEntities.ELMAH_Error.Default dataItem, int row)
            {
                char cell = 'A';

                string cellKey;

                cellKey = GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.ElmahApplication_Name;

                cellKey = GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.ErrorId;

                cellKey = GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.ElmahHost_Name;

                cellKey = GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.ElmahSource_Name;

                cellKey = GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.ElmahStatusCode_Name;

                cellKey = GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.ElmahType_Name;

                cellKey = GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.ElmahUser_Name;

                cellKey = GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.Application;

                cellKey = GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.Host;

                cellKey = GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.Type;

                cellKey = GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.Source;

                cellKey = GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.Message;

                cellKey = GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.User;

                cellKey = GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.StatusCode;

                cellKey = GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.TimeUtc;

                cellKey = GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.Sequence;

                cellKey = GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.AllXml;
            }
コード例 #15
0
            public override void WriteHeaderLineToClosedXmlWorkSheet(ClosedXML.Excel.IXLWorksheet worksheet, int row)
            {
                char cell = 'A';

                string cellKey;

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "Build_1_Name";

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "Id";

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "Solution_1Id";

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "Solution_1_Name";

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "Organization_1_UniqueidentifierColumn";

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "Organization_1_UniqueIdentifier";

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "Organization_1Id";

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "Organization_1_Name";

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "Organization_2_UniqueidentifierColumn";

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "Organization_2Id";

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "Organization_2_UniqueIdentifier";

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "Organization_2_Name";

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "BuildEventCode_1_Name";

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "BuildId";

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "BuildEventCodeId";

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "Message";

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "EventTime";
            }
コード例 #16
0
        private void setHeaderStyle(ClosedXML.Excel.IXLWorksheet sheet, int startCellRow, int startCellCol, int endCellRow, int endCellCol)
        {
            var rang = sheet.Range(startCellRow, startCellCol, endCellRow, endCellCol);

            rang.Style.Font.Bold            = true;
            rang.Style.Font.FontColor       = ClosedXML.Excel.XLColor.White;
            rang.Style.Fill.BackgroundColor = ClosedXML.Excel.XLColor.LightGray;
            formateCells(rang);
        }
コード例 #17
0
            public override void WriteDataItemToClosedXmlWorkSheet(ClosedXML.Excel.IXLWorksheet worksheet, MSBuildLogsExtended.DataSourceEntities.Build.UpdateNameRequest dataItem, int row)
            {
                char cell = 'A';

                string cellKey;

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.Id;

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.Name;
            }
コード例 #18
0
            public override void WriteHeaderLineToClosedXmlWorkSheet(ClosedXML.Excel.IXLWorksheet worksheet, int row)
            {
                char cell = 'A';

                string cellKey;

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "Id";

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "EventCode";
            }
コード例 #19
0
            public override void WriteDataItemToClosedXmlWorkSheet(ClosedXML.Excel.IXLWorksheet worksheet, MSBuildExtensionPack.DataSourceEntities.BuildEventCode.KeyInformation dataItem, int row)
            {
                char cell = 'A';

                string cellKey;

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.Id;

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.EventCode;
            }
コード例 #20
0
ファイル: XLSXReport.cs プロジェクト: H0K5/SharesMapper
        /// <summary>
        /// Write a share ACL into worksheet and the evolution of his ACL.
        /// </summary>
        /// <param name="worksheet"></param>
        /// <param name="shareACL"></param>
        /// <param name="row">Row number to start from</param>
        /// <returns>First free row number</returns>
        static int WriteShare(ClosedXML.Excel.IXLWorksheet worksheet, SMBShareACL shareACL, int row)
        {
            if (Config.Debug)
            {
                Console.WriteLine("[*] Writing share on " + row.ToString() + " " + shareACL.share.ToString() + " ACLs ...");
            }
            int col = 1;

            if (shareACL.shareACL.Count > 0)
            {
                row = InsertACL(
                    worksheet,
                    shareACL.share.hostname,
                    shareACL.share.ToString(),
                    shareACL.share.shareInfo.shi1_remark,
                    0,
                    shareACL.shareACL,
                    row,
                    null,
                    (shareACL.shareACLEvolution.Count > 0) ? shareACL.shareACLEvolution.First().Value.Keys.ToList() : null
                    );
            }
            else
            {
                worksheet.Cell(row, col++).Value = shareACL.share.hostname;
                worksheet.Cell(row, col++).Value = shareACL.share.ToString();
                worksheet.Cell(row, col++).Value = shareACL.share.shareInfo.shi1_remark;
                worksheet.Cell(row, col++).Value = 0;
                worksheet.Cell(row, col++).Value = "No ACE";
                worksheet.Cell(row, col++).Value = "";
                worksheet.Cell(row, col++).Value = shareACL.discoveryDateTime;
                row++;
            }

            if (shareACL.shareACLEvolution.Count > 0)
            {
                row = InsertACLEvolution(
                    worksheet,
                    shareACL.share.hostname,
                    shareACL.share.ToString(),
                    shareACL.share.shareInfo.shi1_remark,
                    0,
                    shareACL.shareACLEvolution,
                    row,
                    shareACL.shareACL.Keys.ToList()
                    );
            }

            return(row);
        }
コード例 #21
0
            public override void WriteDataItemToClosedXmlWorkSheet(ClosedXML.Excel.IXLWorksheet worksheet, MSBuildExtensionPack.DataSourceEntities.Build.Default dataItem, int row)
            {
                char cell = 'A';

                string cellKey;

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.Solution_1_Name;

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.Id;

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.Organization_1Id;

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.Organization_1_UniqueIdentifier;

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.Organization_1_UniqueidentifierColumn;

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.Organization_1_Name;

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.Organization_2Id;

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.Organization_2_UniqueIdentifier;

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.Organization_2_UniqueidentifierColumn;

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.Organization_2_Name;

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.SolutionId;

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.Name;

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.Description;

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.BuildStartTime;
            }
コード例 #22
0
        public override void WriteDataItemToClosedXmlWorkSheet(ClosedXML.Excel.IXLWorksheet worksheet, MSBuildLogsExtended.DataSourceEntities.Solution dataItem, int row)
        {
            char cell = 'A';

            string cellKey;

            cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
            worksheet.Cell(cellKey).Value = dataItem.Id;

            cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
            worksheet.Cell(cellKey).Value = dataItem.ExternalParentId;

            cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
            worksheet.Cell(cellKey).Value = dataItem.Name;

            cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
            worksheet.Cell(cellKey).Value = dataItem.Description;
        }
コード例 #23
0
            public override void WriteHeaderLineToClosedXmlWorkSheet(ClosedXML.Excel.IXLWorksheet worksheet, int row)
            {
                char cell = 'A';

                string cellKey;

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "Organization_1_UniqueIdentifier";

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "Organization_1_UniqueidentifierColumn";

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "Organization_1_Name";

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "Id";

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "Organization_2Id";

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "Organization_2_UniqueIdentifier";

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "Organization_2_UniqueidentifierColumn";

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "Organization_2_Name";

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "ExternalParentId";

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "Name";

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "Description";

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "OrganizationId";
            }
コード例 #24
0
        public override void WriteHeaderLineToClosedXmlWorkSheet(ClosedXML.Excel.IXLWorksheet worksheet, int row)
        {
            char cell = 'A';

            string cellKey;

            cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
            worksheet.Cell(cellKey).Value = "Id";

            cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
            worksheet.Cell(cellKey).Value = "SolutionId";

            cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
            worksheet.Cell(cellKey).Value = "Name";

            cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
            worksheet.Cell(cellKey).Value = "Description";

            cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
            worksheet.Cell(cellKey).Value = "BuildStartTime";
        }
コード例 #25
0
        public string[,] OpenExcel(string filename)
        {
            using (ClosedXML.Excel.XLWorkbook workbook = new ClosedXML.Excel.XLWorkbook(filename))
            {
                ClosedXML.Excel.IXLWorksheet worksheet = workbook.Worksheet(1);
                int rc = worksheet.RangeUsed().RowCount();
                int cc = worksheet.RangeUsed().Row(1).CellCount();
                string[,] buff = new string[rc, cc];
                for (int i = 0; i < rc; i++)
                {
                    ClosedXML.Excel.IXLRow row = worksheet.Row(i + 1);
                    for (int j = 0; j < cc; j++)
                    {
                        ClosedXML.Excel.IXLCell cell = row.Cell(j + 1);
                        string value = cell.GetValue <string>();
                        buff[i, j] = value;
                    }
                }

                return(buff);
            }
        }
コード例 #26
0
ファイル: XLSXReport.cs プロジェクト: H0K5/SharesMapper
        /// <summary>
        /// Write the first row on the Excel worksheet.
        /// </summary>
        /// <param name="worksheet">An Excel worksheet object on which we write</param>
        /// <param name="row">The row number where to write</param>
        /// <param name="col">The column number where to write</param>
        /// <returns>The next empty row</returns>
        private static int WriteHeader(ClosedXML.Excel.IXLWorksheet worksheet, int row = 1, int col = 1)
        {
            worksheet.Cell(row, col++).Value = "Hostname";
            worksheet.Cell(row, col++).Value = "UNC Path";
            worksheet.Cell(row, col++).Value = "Remark";
            worksheet.Cell(row, col++).Value = "Level";
            worksheet.Cell(row, col++).Value = "ACE status";
            worksheet.Cell(row, col++).Value = "ACE_ID";
            worksheet.Cell(row, col++).Value = "DateTime";
            worksheet.Cell(row, col++).Value = "AccessControlType";
            worksheet.Cell(row, col++).Value = "CompactReadableFileSystemRights";
            worksheet.Cell(row, col++).Value = "ReadableFileSystemRights";
            worksheet.Cell(row, col++).Value = "ReadableIdentityReference";
            worksheet.Cell(row, col++).Value = "IdentityReference";
            worksheet.Cell(row, col++).Value = "Owner";
            worksheet.Cell(row, col++).Value = "OwnerSID";
            worksheet.Cell(row, col++).Value = "IsInherited";
            worksheet.Cell(row, col++).Value = "InheritanceFlags";
            worksheet.Cell(row, col++).Value = "PropagationFlags";
            col = 1;

            return(++row);
        }
コード例 #27
0
        private void ScriviOre(
            ClosedXML.Excel.IXLWorksheet meseSheet, List <RowExcel> dataOutput)
        {
            int row = 3;

            var it = new CultureInfo("it-IT");

            while (dataOutput.Count() > 0)
            {
                var itemRowOutput = dataOutput.Select(a => a).OrderBy(a => a.Data).FirstOrDefault();
                dataOutput.Remove(itemRowOutput);

                if (!meseSheet.Cell(row, 4).IsEmpty())
                {
                    meseSheet.Row(row).InsertRowsBelow(1);
                    row++;
                }
                meseSheet.Cell(row, 1).Value = itemRowOutput.Data.ToString("dd/MM/yyyy");
                meseSheet.Cell(row, 2).Value = itemRowOutput.Data.ToString("ddd", it);
                meseSheet.Cell(row, 3).Value = System.Globalization.ISOWeek.GetWeekOfYear(itemRowOutput.Data);


                meseSheet.Cell(row, 4).Value = itemRowOutput.Commessa;
                meseSheet.Cell(row, 6).Value = itemRowOutput.NumeroOre;

                meseSheet.Cell(row, 5).Value = itemRowOutput.SedeLavoro;

                if (itemRowOutput.Pasto)
                {
                    Pernotto(meseSheet, row);
                }



                row++;
            }
        }
コード例 #28
0
            public override void WriteHeaderLineToClosedXmlWorkSheet(ClosedXML.Excel.IXLWorksheet worksheet, int row)
            {
                char cell = 'A';

                string cellKey;

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "Id";

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "Name";

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "IsSystemBuiltIn";

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "UniqueIdentifier";

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "BitColumn";

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = "UniqueidentifierColumn";
            }
コード例 #29
0
            public override void WriteDataItemToClosedXmlWorkSheet(ClosedXML.Excel.IXLWorksheet worksheet, MSBuildExtensionPack.DataSourceEntities.Organization.KeyInformation dataItem, int row)
            {
                char cell = 'A';

                string cellKey;

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.Id;

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.Name;

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.IsSystemBuiltIn;

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.UniqueIdentifier;

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.BitColumn;

                cellKey = Framework.Services.ClosedXmlHelper.GetCellKey(row, cell++);
                worksheet.Cell(cellKey).Value = dataItem.UniqueidentifierColumn;
            }
コード例 #30
0
ファイル: XLSXReport.cs プロジェクト: H0K5/SharesMapper
        /// <summary>
        /// Write ACL into worksheet.
        /// </summary>
        /// <param name="worksheet"></param>
        /// <param name="hostname"></param>
        /// <param name="shareName"></param>
        /// <param name="remark"></param>
        /// <param name="level"></param>
        /// <param name="acl"></param>
        /// <param name="row">Row number to start from</param>
        /// <param name="lastScan">List of ACE_ID of the previous scan</param>
        /// <param name="nextScan">List of ACE_ID of the scan after the current one</param>
        /// <returns></returns>
        static int InsertACL(ClosedXML.Excel.IXLWorksheet worksheet, string hostname, string shareName, string remark, int level, Dictionary <string, Dictionary <string, string> > acl, int row, List <string> lastScan = null, List <string> nextScan = null)
        {
            int col = 1;

            if (acl.Count > 0)
            {
                foreach (var entry in acl)
                {
                    if (Config.Debug && entry.Key != "noACE")
                    {
                        Console.WriteLine("[*] Writing share ACE on " + row.ToString() + " " + entry.Value["AccessControlType"] + " " + entry.Value["ReadableFileSystemRights"] + " to " + entry.Value["ReadableIdentityReference"] + " on " + shareName);
                    }
                    worksheet.Cell(row, col++).Value = hostname;
                    worksheet.Cell(row, col++).Value = shareName;
                    worksheet.Cell(row, col++).Value = remark;
                    worksheet.Cell(row, col++).Value = level;

                    if (entry.Key == "noACE")
                    {
                        worksheet.Cell(row, col++).Value = "No ACE";
                        worksheet.Cell(row, col++).Value = "";
                        worksheet.Cell(row, col++).Value = entry.Value["DiscoveryDateTime"];
                    }
                    else
                    {
                        if (nextScan != null && lastScan != null)
                        {
                            if (lastScan.Contains(entry.Value["IdentityReference"] + "-" + entry.Value["FileSystemRights"]) && nextScan.Contains(entry.Value["IdentityReference"] + "-" + entry.Value["FileSystemRights"]))
                            {
                                worksheet.Cell(row, col++).Value = "No change";
                            }
                            else if (!lastScan.Contains(entry.Value["IdentityReference"] + "-" + entry.Value["FileSystemRights"]) && nextScan.Contains(entry.Value["IdentityReference"] + "-" + entry.Value["FileSystemRights"]))
                            {
                                worksheet.Cell(row, col++).Value = "New ACE";
                            }
                            else if (lastScan.Contains(entry.Value["IdentityReference"] + "-" + entry.Value["FileSystemRights"]) && !nextScan.Contains(entry.Value["IdentityReference"] + "-" + entry.Value["FileSystemRights"]))
                            {
                                worksheet.Cell(row, col++).Value = "ACE Removed ";
                            }
                            else
                            {
                                worksheet.Cell(row, col++).Value = "ACE Removed";
                            }
                        }
                        else if (nextScan != null)
                        {
                            worksheet.Cell(row, col++).Value = nextScan.Contains(entry.Value["IdentityReference"] + "-" + entry.Value["FileSystemRights"]) ? "New ACE" : "ACE removed";
                        }
                        else if (lastScan != null)
                        {
                            worksheet.Cell(row, col++).Value = lastScan.Contains(entry.Value["IdentityReference"] + "-" + entry.Value["FileSystemRights"]) ? "No change" : "New ACE";
                        }
                        else
                        {
                            worksheet.Cell(row, col++).Value = "New ACE";
                        }
                        worksheet.Cell(row, col++).Value = entry.Value["IdentityReference"] + "-" + entry.Value["FileSystemRights"];
                        worksheet.Cell(row, col++).Value = entry.Value["DiscoveryDateTime"];
                        worksheet.Cell(row, col++).Value = entry.Value["AccessControlType"];
                        worksheet.Cell(row, col++).Value = entry.Value["CompactReadableFileSystemRights"];
                        worksheet.Cell(row, col++).Value = entry.Value["ReadableFileSystemRights"];
                        worksheet.Cell(row, col++).Value = (entry.Value["ReadableIdentityReference"].StartsWith("S-1-5")) ? TranslateSid(entry.Value["ReadableIdentityReference"]) : entry.Value["ReadableIdentityReference"];
                        worksheet.Cell(row, col++).Value = entry.Value["IdentityReference"];
                        worksheet.Cell(row, col++).Value = (entry.Value["Owner"].StartsWith("S-1-5")) ? TranslateSid(entry.Value["Owner"]) : entry.Value["Owner"];
                        worksheet.Cell(row, col++).Value = entry.Value["OwnerSID"];
                        worksheet.Cell(row, col++).Value = entry.Value["IsInherited"];
                        worksheet.Cell(row, col++).Value = entry.Value["InheritanceFlags"];
                        worksheet.Cell(row, col++).Value = entry.Value["PropagationFlags"];
                    }
                    col = 1;
                    row++;
                }
            }

            return(row);
        }