diff --git a/OpenXmlFormats/Wordprocessing/Document.cs b/OpenXmlFormats/Wordprocessing/Document.cs index 048caf497..3c44948ca 100644 --- a/OpenXmlFormats/Wordprocessing/Document.cs +++ b/OpenXmlFormats/Wordprocessing/Document.cs @@ -109,7 +109,7 @@ internal void Write(StreamWriter sw) public CT_Document() { - //this.bodyField = new CT_Body(); + this.bodyField = new CT_Body(); } [XmlElement(Order = 0)] @@ -147,7 +147,7 @@ public class CT_Body public CT_Body() { - //this.sectPrField = new CT_SectPr(); + this.sectPrField = new CT_SectPr(); this.itemsElementNameField = new List(); this.itemsField = new ArrayList(); } diff --git a/OpenXmlFormats/Wordprocessing/Paragraph.cs b/OpenXmlFormats/Wordprocessing/Paragraph.cs index 4ac43ca89..4e10142f6 100644 --- a/OpenXmlFormats/Wordprocessing/Paragraph.cs +++ b/OpenXmlFormats/Wordprocessing/Paragraph.cs @@ -756,6 +756,11 @@ public class CT_PPr : CT_PPrBase public CT_PPr() { + } + public CT_SectPr createSectPr() + { + this.sectPrField = new CT_SectPr(); + return this.sectPrField; } public override bool IsEmpty { @@ -1898,7 +1903,7 @@ public class CT_SectPrChange : CT_TrackChange public CT_SectPrChange() { - //this.sectPrField = new CT_SectPrBase(); + this.sectPrField = new CT_SectPrBase(); } public static new CT_SectPrChange Parse(XmlNode node, XmlNamespaceManager namespaceManager) { @@ -2004,12 +2009,12 @@ public CT_SectPrBase() //this.docGridField = new CT_DocGrid(); //this.rtlGutterField = new CT_OnOff(); //this.bidiField = new CT_OnOff(); - //this.textDirectionField = new CT_TextDirection(); + this.textDirectionField = new CT_TextDirection(); //this.titlePgField = new CT_OnOff(); //this.noEndnoteField = new CT_OnOff(); //this.vAlignField = new CT_VerticalJc(); //this.formProtField = new CT_OnOff(); - //this.colsField = new CT_Columns(); + this.colsField = new CT_Columns(); //this.pgNumTypeField = new CT_PageNumber(); //this.lnNumTypeField = new CT_LineNumber(); //this.pgBordersField = new CT_PageBorders(); @@ -2481,7 +2486,7 @@ public class CT_SectPr public CT_SectPr() { - //this.sectPrChangeField = new CT_SectPrChange(); + this.sectPrChangeField = new CT_SectPrChange(); //this.printerSettingsField = new CT_Rel(); this.docGridField = new CT_DocGrid(); this.docGrid.type = ST_DocGrid.lines; @@ -2490,7 +2495,7 @@ public CT_SectPr() //this.rtlGutterField = new CT_OnOff(); //this.bidiField = new CT_OnOff(); - //this.textDirectionField = new CT_TextDirection(); + this.textDirectionField = new CT_TextDirection(); //this.titlePgField = new CT_OnOff(); //this.noEndnoteField = new CT_OnOff(); //this.vAlignField = new CT_VerticalJc(); @@ -2498,7 +2503,7 @@ public CT_SectPr() this.colsField = new CT_Columns(); this.cols.space = 425; this.cols.spaceSpecified = true; - //this.pgNumTypeField = new CT_PageNumber(); + this.pgNumTypeField = new CT_PageNumber(); //this.lnNumTypeField = new CT_LineNumber(); //this.pgBordersField = new CT_PageBorders(); //this.paperSrcField = new CT_PaperSource(); @@ -3502,7 +3507,10 @@ public bool IsSetLineRule() { return !(this.lineRuleField == ST_LineSpacingRule.nil); } - + public bool IsSetBetweenLines() + { + return !string.IsNullOrEmpty(this.lineField); + } public bool IsSetAfter() { return !(this.afterField == 0); diff --git a/main/HSSF/UserModel/HSSFCell.cs b/main/HSSF/UserModel/HSSFCell.cs index 7818eeebd..288114d81 100644 --- a/main/HSSF/UserModel/HSSFCell.cs +++ b/main/HSSF/UserModel/HSSFCell.cs @@ -496,7 +496,7 @@ public void SetCellValue(double value) /// will Change the cell to a numeric cell and Set its value. public void SetCellValue(DateTime value) { - SetCellValue(DateUtil.GetExcelDate(value, this.book.Workbook.IsUsing1904DateWindowing)); + SetCellValue(DateUtil.GetExcelDate(value, this.book.IsDate1904())); } @@ -761,7 +761,7 @@ public DateTime DateCellValue "You cannot get a date value from an error cell"); } double value = this.NumericCellValue; - if (book.Workbook.IsUsing1904DateWindowing) + if (book.IsDate1904()) { return DateUtil.GetJavaDate(value, true); } diff --git a/main/HSSF/UserModel/HSSFWorkbook.cs b/main/HSSF/UserModel/HSSFWorkbook.cs index 077b1f5c8..8409b3ea9 100644 --- a/main/HSSF/UserModel/HSSFWorkbook.cs +++ b/main/HSSF/UserModel/HSSFWorkbook.cs @@ -2266,5 +2266,16 @@ public bool Remove(ISheet item) { return this._sheets.Remove((HSSFSheet)item); } + + /// + /// Gets a bool value that indicates whether the date systems used in the workbook starts in 1904. + /// The default value is false, meaning that the workbook uses the 1900 date system, + /// where 1/1/1900 is the first day in the system. + /// + /// True if the date systems used in the workbook starts in 1904 + public bool IsDate1904() + { + return Workbook.IsUsing1904DateWindowing; + } } } diff --git a/main/SS/UserModel/Workbook.cs b/main/SS/UserModel/Workbook.cs index 7d527dca0..6370775fd 100644 --- a/main/SS/UserModel/Workbook.cs +++ b/main/SS/UserModel/Workbook.cs @@ -423,6 +423,14 @@ public interface IWorkbook : ICloseable /// the toolpack to register void AddToolPack(UDFFinder toopack); + /// + /// Gets a bool value that indicates whether the date systems used in the workbook starts in 1904. + /// The default value is false, meaning that the workbook uses the 1900 date system, + /// where 1/1/1900 is the first day in the system. + /// + /// True if the date systems used in the workbook starts in 1904 + bool IsDate1904(); + void Close(); /// diff --git a/ooxml/XSSF/Streaming/SXSSFCell.cs b/ooxml/XSSF/Streaming/SXSSFCell.cs index 2df39ead9..06be5fd89 100644 --- a/ooxml/XSSF/Streaming/SXSSFCell.cs +++ b/ooxml/XSSF/Streaming/SXSSFCell.cs @@ -176,7 +176,7 @@ public DateTime DateCellValue } double value = NumericCellValue; - bool date1904= ((XSSFWorkbook)Sheet.Workbook).IsDate1904(); + bool date1904 = Sheet.Workbook.IsDate1904(); return DateUtil.GetJavaDate(value, date1904); } } @@ -475,8 +475,7 @@ public void SetCellValue(DateTime? value) return; } - bool date1904 = ((XSSFWorkbook)Sheet.Workbook).IsDate1904(); - SetCellValue(DateUtil.GetExcelDate(value.Value, date1904)); + SetCellValue(value.Value); } public void SetCellValue(double value) @@ -788,7 +787,8 @@ private String ConvertCellValueToString(CellType cellType) public void SetCellValue(DateTime value) { - SetCellValue((DateTime?)value); + bool date1904 = Sheet.Workbook.IsDate1904(); + SetCellValue(DateUtil.GetExcelDate(value, date1904)); } } } diff --git a/ooxml/XSSF/Streaming/SXSSFSheet.cs b/ooxml/XSSF/Streaming/SXSSFSheet.cs index cac14c698..893602ee2 100644 --- a/ooxml/XSSF/Streaming/SXSSFSheet.cs +++ b/ooxml/XSSF/Streaming/SXSSFSheet.cs @@ -1156,7 +1156,7 @@ public void UngroupRow(int fromRow, int toRow) public bool IsDate1904() { - throw new NotImplementedException(); + return _workbook.IsDate1904(); } public int GetRowNum(SXSSFRow row) { diff --git a/ooxml/XSSF/Streaming/SXSSFWorkbook.cs b/ooxml/XSSF/Streaming/SXSSFWorkbook.cs index 968d05f04..0eaccfc4e 100644 --- a/ooxml/XSSF/Streaming/SXSSFWorkbook.cs +++ b/ooxml/XSSF/Streaming/SXSSFWorkbook.cs @@ -736,10 +736,6 @@ public ICreationHelper GetCreationHelper() { return new SXSSFCreationHelper(this); } - protected bool IsDate1904() - { - return XssfWorkbook.IsDate1904(); - } public bool IsSheetHidden(int sheetIx) { return XssfWorkbook.IsSheetHidden(sheetIx); @@ -777,6 +773,16 @@ public SpreadsheetVersion SpreadsheetVersion } } + /// + /// Gets a bool value that indicates whether the date systems used in the workbook starts in 1904. + /// The default value is false, meaning that the workbook uses the 1900 date system, + /// where 1/1/1900 is the first day in the system. + /// + /// True if the date systems used in the workbook starts in 1904 + public bool IsDate1904() + { + return XssfWorkbook.IsDate1904(); + } //TODO: missing method isDate1904, isHidden, setHidden } } diff --git a/ooxml/XSSF/UserModel/XSSFCell.cs b/ooxml/XSSF/UserModel/XSSFCell.cs index c8b2ee8ea..9cbecbba9 100644 --- a/ooxml/XSSF/UserModel/XSSFCell.cs +++ b/ooxml/XSSF/UserModel/XSSFCell.cs @@ -786,7 +786,7 @@ public DateTime DateCellValue } double value = NumericCellValue; - bool date1904 = ((XSSFWorkbook)Sheet.Workbook).IsDate1904(); + bool date1904 = Sheet.Workbook.IsDate1904(); return DateUtil.GetJavaDate(value, date1904); } } @@ -798,7 +798,7 @@ public DateTime DateCellValue /// for numerics we'll Set its value. For other types we will change the cell to a numeric cell and Set its value. public void SetCellValue(DateTime value) { - bool date1904 = ((XSSFWorkbook)Sheet.Workbook).IsDate1904(); + bool date1904 = Sheet.Workbook.IsDate1904(); SetCellValue(DateUtil.GetExcelDate(value, date1904)); } /// diff --git a/ooxml/XSSF/UserModel/XSSFWorkbook.cs b/ooxml/XSSF/UserModel/XSSFWorkbook.cs index 691cb9f6a..ea9f80867 100644 --- a/ooxml/XSSF/UserModel/XSSFWorkbook.cs +++ b/ooxml/XSSF/UserModel/XSSFWorkbook.cs @@ -1796,14 +1796,12 @@ private bool ContainsSheet(String name, int excludeSheetIdx) return false; } - /** - * Gets a bool value that indicates whether the date systems used in the workbook starts in 1904. - *

- * The default value is false, meaning that the workbook uses the 1900 date system, - * where 1/1/1900 is the first day in the system.. - *

- * @return true if the date systems used in the workbook starts in 1904 - */ + /// + /// Gets a bool value that indicates whether the date systems used in the workbook starts in 1904. + /// The default value is false, meaning that the workbook uses the 1900 date system, + /// where 1/1/1900 is the first day in the system. + /// + /// True if the date systems used in the workbook starts in 1904 public bool IsDate1904() { CT_WorkbookPr workbookPr = workbook.workbookPr; diff --git a/ooxml/XWPF/Usermodel/XWPFDocument.cs b/ooxml/XWPF/Usermodel/XWPFDocument.cs index 556f26698..c40f07c43 100644 --- a/ooxml/XWPF/Usermodel/XWPFDocument.cs +++ b/ooxml/XWPF/Usermodel/XWPFDocument.cs @@ -293,8 +293,48 @@ public CT_Document Document { return ctDocument; } + set + { + ctDocument = value; + } } + /** + * Sets columns on document base object + */ + public int ColumnCount + { + get + { + return int.Parse(ctDocument.body.sectPr.cols.num); + } + set + { + if (ctDocument != null) + { + ctDocument.body.sectPr.cols.num = value.ToString(); + } + } + + } + /** + * Sets Text Direction of Document + */ + public ST_TextDirection TextDirection + { + get + { + return ctDocument.body.sectPr.textDirection.val; + } + set + { + if (ctDocument != null) + { + ctDocument.body.sectPr.textDirection.val = value; + } + } + + } internal IdentifierManager DrawingIdManager { get diff --git a/ooxml/XWPF/Usermodel/XWPFHeaderFooter.cs b/ooxml/XWPF/Usermodel/XWPFHeaderFooter.cs index d7cea1ac4..c07a26dc2 100644 --- a/ooxml/XWPF/Usermodel/XWPFHeaderFooter.cs +++ b/ooxml/XWPF/Usermodel/XWPFHeaderFooter.cs @@ -53,8 +53,8 @@ public XWPFHeaderFooter(XWPFDocument doc, CT_HdrFtr hdrFtr) protected XWPFHeaderFooter() { - //headerFooter = new CT_HdrFtr(); - //ReadHdrFtr(); + headerFooter = new CT_HdrFtr(); + ReadHdrFtr(); } public XWPFHeaderFooter(POIXMLDocumentPart parent, PackagePart part) diff --git a/ooxml/XWPF/Usermodel/XWPFParagraph.cs b/ooxml/XWPF/Usermodel/XWPFParagraph.cs index dcf5ce58d..da39e2318 100644 --- a/ooxml/XWPF/Usermodel/XWPFParagraph.cs +++ b/ooxml/XWPF/Usermodel/XWPFParagraph.cs @@ -579,9 +579,11 @@ public ParagraphAlignment Alignment } } + /** * @return The raw alignment value, {@link #getAlignment()} is suggested */ + public int FontAlignment { get @@ -987,6 +989,36 @@ public LineSpacingRule SpacingLineRule } } + /// + /// Return the spacing between lines of a paragraph. The units of the return value depends on the + /// . If AUTO, the return value is in lines, otherwise the return + /// value is in points + /// + /// a double specifying points or lines. + /// + public double SpacingBetween + { + set + { + setSpacingBetween(value, LineSpacingRule.AUTO); + } + + } + public void setSpacingBetween(double spacing, LineSpacingRule rule) + { + CT_Spacing ctSp = GetCTSpacing(true); + switch(rule) + { + case LineSpacingRule.AUTO: + ctSp.line = Math.Round(spacing * 240.0).ToString(); + break; + default: + ctSp.line = Math.Round(spacing * 20.0).ToString(); + break; + } + ctSp.lineRule = EnumConverter.ValueOf(rule); + + } /** * Specifies the indentation which shall be placed between the left text