public bool SetPageRange(string tabText) { string address = this.axSpreadsheet1.Selection.Address; if (address.IndexOf(":") < 0) { MessageBox.Show("选择区域不合理。不能只是一个单元格。", "卡片模板", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } string str2 = address.Substring(0, address.IndexOf(":")); string str3 = address.Substring(address.IndexOf(":") + 1); if (!CLPPFile.CheckAddress(str2) || !CLPPFile.CheckAddress(str3)) { MessageBox.Show("选择区域不合理。不能只是一行或者一列。", "卡片模板", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } if (str2 != "A1") { MessageBox.Show("必须从A1单元格开始选择区域。", "卡片模板", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } try { this.axSpreadsheet1.ViewableRange = address; } catch { MessageBox.Show("选择区域不合理。要确保选择区域所有单元格(特别是合并形成的单元格)都是完整的。", "卡片模板", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } if (MessageBox.Show(tabText + "有效区域已经重新设置,是否保存这些设置?请注意:模板定制时如果插入、删除行和列,必须重新设置模板的有效区域和表中区域。", "卡片模板", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { string str4 = "A1:" + PPCConvert.RowCol2Address(this.countRows, this.countColumns); this.axSpreadsheet1.ViewableRange = str4; return(false); } this.countRows = PPCConvert.Address2Row(str3); this.countColumns = PPCConvert.Address2Col(str3); string str5 = tabText; if (str5 != null) { if (str5 == "封面") { this.m_tp.RowCountOfCover = this.countRows; this.m_tp.ColCountOfCover = this.countColumns; } else if (str5 == "首页") { this.m_tp.RowCountOfMain = this.countRows; this.m_tp.ColCountOfMain = this.countColumns; } else if (str5 == "续页") { this.m_tp.RowCountOfNext = this.countRows; this.m_tp.ColCountOfNext = this.countColumns; } } return(true); }
private void InitializeSheet(bool readOnly) { try { string str = "A1:" + PPCConvert.RowCol2Address(this.countRows, this.countColumns); this.axSpreadsheet1.ViewableRange = str; } catch { this.axSpreadsheet1.ViewableRange = "A1:CZ100"; MessageBox.Show("模板的总行数或者总列数不合理。有效区域已重置,请仔细检查,并重新设置有效区域。"); } this.ReadOnly = readOnly; }
private void GetColList(ArrayList midColLstOfMain, ArrayList midColLstOfNext) { try { if (this.m_tp != null) { int num = PPCConvert.Address2Col(this.m_tp.MidBeginOfMain); int num2 = PPCConvert.Address2Col(this.m_tp.MidEndOfMain); int num3 = PPCConvert.Address2Col(this.m_tp.MidBeginOfNext); int num4 = PPCConvert.Address2Col(this.m_tp.MidEndOfNext); int row = PPCConvert.Address2Row(this.m_tp.MidBeginOfMain); int num6 = PPCConvert.Address2Row(this.m_tp.MidBeginOfNext); if (base.Parent.Text == "首页") { for (int i = num; i <= num2; i++) { if (this.GetFirstCell(PPCConvert.RowCol2Address(row, i)) == PPCConvert.RowCol2Address(row, i)) { midColLstOfMain.Add(PPCConvert.Int2ABC(i)); midColLstOfNext.Add(PPCConvert.Int2ABC(i)); } } } else if (base.Parent.Text == "续页") { for (int j = num3; j <= num4; j++) { if (this.GetFirstCell(PPCConvert.RowCol2Address(num6, j)) == PPCConvert.RowCol2Address(num6, j)) { midColLstOfNext.Add(PPCConvert.Int2ABC(j)); midColLstOfMain.Add(PPCConvert.Int2ABC(j)); } } } } } catch (Exception exception) { throw new Exception("获取首页或续页的表中有效列出错。" + exception.Message); } }
private void SetDefaultColor(PPTmpPage comparedPage) { this.SetFontColor(this.GetRange("A1", PPCConvert.RowCol2Address(this.countRows, this.countColumns)), "Black"); comparedPage.SetFontColor(comparedPage.GetRange("A1", PPCConvert.RowCol2Address(comparedPage.countRows, comparedPage.countColumns)), "Black"); }
private void SetColColor(int colStart, int colEnd, int row) { OWC.Range r = this.GetRange(PPCConvert.RowCol2Address(1, colStart), PPCConvert.RowCol2Address(row, colEnd)); this.SetFontColor(r, "Fuchsia"); }
private void SetRowColor(int rowStart, int rowEnd, int col) { OWC.Range r = this.GetRange(PPCConvert.RowCol2Address(rowStart, 1), PPCConvert.RowCol2Address(rowEnd, col)); this.SetFontColor(r, "Fuchsia"); }