/// <summary> /// Removes hidden data of Xls file /// </summary> public static void RemoveHiddenData() { try { //ExStart:RemoveHiddenDataInXls // initialize XlsFormat XlsFormat xlsFormat = new XlsFormat(Common.MapSourceFilePath(filePath)); // get hidden data XlsInspectionResult hiddenData = xlsFormat.InspectDocument(); // get hidden sheets XlsSheet[] hiddenSheets = hiddenData.HiddenSheets; // display hidden fields if (hiddenSheets.Length > 0) { // clear hidden sheets xlsFormat.RemoveHiddenData(new XlsInspectionOptions(XlsInspectorOptionsEnum.HiddenSheets)); Console.WriteLine("Hidden sheets removed."); // and commit changes xlsFormat.Save(); Console.WriteLine("Changes save successfully!"); } else Console.WriteLine("No sheets found."); //ExEnd:RemoveHiddenDataInXls } catch (Exception exp) { Console.WriteLine(exp.Message); } }
/// <summary> /// Gets comments and hidden sheets of Xls file /// </summary> public static void GetHiddenData() { try { //ExStart:GetHiddenDataInXls // initialize XlsFormat XlsFormat xlsFormat = new XlsFormat(Common.MapSourceFilePath(filePath)); // get hidden data XlsInspectionResult hiddenData = xlsFormat.InspectDocument(); // get hidden sheets XlsSheet[] hiddenSheets = hiddenData.HiddenSheets; // get comments XlsComment[] comments = hiddenData.Comments; if (comments.Length > 0) { foreach (XlsComment comment in comments) { Console.WriteLine("Comment: {0}, Column: {1}", comment.ToString(), comment.Column); } } else { Console.WriteLine("No comment found!"); } //ExEnd:GetHiddenDataInXls } catch (Exception exp) { Console.WriteLine(exp.Message); } }