本文整理汇总了C#中IXLWorksheet.Range方法的典型用法代码示例。如果您正苦于以下问题:C# IXLWorksheet.Range方法的具体用法?C# IXLWorksheet.Range怎么用?C# IXLWorksheet.Range使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IXLWorksheet
的用法示例。
在下文中一共展示了IXLWorksheet.Range方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Format
public void Format(IXLWorksheet worksheet, Table table, ref int row)
{
int startRow = row;
int headerColumn = TableStartColumn;
foreach (string cell in table.HeaderRow)
{
worksheet.Cell(row, headerColumn).Style.Font.SetBold();
worksheet.Cell(row, headerColumn).Style.Font.SetItalic();
worksheet.Cell(row, headerColumn).Style.Fill.SetBackgroundColor(XLColor.AliceBlue);
worksheet.Cell(row, headerColumn++).Value = cell;
}
row++;
foreach (TableRow dataRow in table.DataRows)
{
int dataColumn = TableStartColumn;
foreach (string cell in dataRow)
{
worksheet.Cell(row, dataColumn++).Value = cell;
}
row++;
}
int lastRow = row - 1;
int lastColumn = headerColumn - 1;
worksheet.Range(startRow, TableStartColumn, lastRow, lastColumn).Style.Border.TopBorder =
XLBorderStyleValues.Thin;
worksheet.Range(startRow, TableStartColumn, lastRow, lastColumn).Style.Border.LeftBorder =
XLBorderStyleValues.Thin;
worksheet.Range(startRow, TableStartColumn, lastRow, lastColumn).Style.Border.BottomBorder =
XLBorderStyleValues.Thin;
worksheet.Range(startRow, TableStartColumn, lastRow, lastColumn).Style.Border.RightBorder =
XLBorderStyleValues.Thin;
}
示例2: Estrai_Template_2017
int Estrai_Template_2017(IXLWorksheet wsAnno, int lastRowNumber, IXLWorksheet dati, int riga)
{
var laura = wsAnno.Range("B1", "F" + lastRowNumber).Rows().Select(Movimento.TryParse2017);
var valerio = wsAnno.Range("G1", "L" + lastRowNumber).Rows().Select(Movimento.TryParse2017);
var comune = wsAnno.Range("L1", "R" + lastRowNumber).Rows().Select(Movimento.TryParse2017);
var movimenti = laura.Concat(valerio).Concat(comune).Where(r => r != null).ToArray();
foreach (var movimento in movimenti)
{
dati.Cell(riga, "A").Value = movimento.Data;
dati.Cell(riga, "B").Value = movimento.Categoria;
dati.Cell(riga, "C").Value = movimento.Per;
dati.Cell(riga, "D").Value = movimento.Descrizione;
dati.Cell(riga, "E").Value = movimento.Spesa;
riga++;
}
return riga;
}
示例3: CopyRowAsRange
private static void CopyRowAsRange(IXLWorksheet originalSheet, int originalRowNumber, IXLWorksheet destSheet, int destRowNumber)
{
{
var destinationRow = destSheet.Row(destRowNumber);
destinationRow.Clear();
var originalRow = originalSheet.Row(originalRowNumber);
int columnNumber = originalRow.LastCellUsed(true).Address.ColumnNumber;
var originalRange = originalSheet.Range(originalRowNumber, 1, originalRowNumber, columnNumber);
var destRange = destSheet.Range(destRowNumber, 1, destRowNumber, columnNumber);
originalRange.CopyTo(destRange);
}
}
示例4: WriteOutNumberOfEntriesPerOrtsTeil
public int WriteOutNumberOfEntriesPerOrtsTeil(IXLWorksheet workSheet,
StatistikRootClass.DistributionCountTyp DistTyp)
{
IXLRange headerRng = workSheet.Range("B2:F2").Merge();
headerRng.Style
.Font.SetBold()
.Fill.SetBackgroundColor(XLColor.AliceBlue)
.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Center)
.Alignment.WrapText = true;
headerRng.Value = "Vorschläge / Ideen Anzahlen " + DistTyp.GetDescription();
switch (DistTyp)
{
case StatistikRootClass.DistributionCountTyp.AllTogether:
{
workSheet.Column("A").Width = 2;
workSheet.Column("G").Width = 2;
IXLRange CounterHeaderRange = workSheet.Range("E4:F4").Merge().SetDataType(XLCellValues.Text);
CounterHeaderRange.Value = "Anzahlen";
CounterHeaderRange.Style
.Font.SetBold()
.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Center)
.Alignment.WrapText = true;
int ColumnNumber = 0;
foreach (string Col in ProjektCounterColumns(DistTyp))
workSheet.Cell($"{ColumnNameTable[ColumnNumber++ + 1]}5").Value = Col;
workSheet.Column("D").Width = 40;
return 7;
}
break;
case StatistikRootClass.DistributionCountTyp.PerAG:
{
workSheet.Column("A").Width = 2;
workSheet.Column("G").Width = 2;
IXLRange CounterHeaderRange = workSheet.Range("E4:F4").Merge().SetDataType(XLCellValues.Text);
CounterHeaderRange.Value = "Anzahlen";
CounterHeaderRange.Style
.Font.SetBold()
.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Center)
.Alignment.WrapText = true;
int ColumnNumber = 0;
foreach (string Col in ProjektCounterColumns(DistTyp))
workSheet.Cell($"{ColumnNameTable[ColumnNumber++ + 1]}5").Value = Col;
workSheet.Column("D").Width = 40;
return 7;
}
break;
case StatistikRootClass.DistributionCountTyp.PerOrtsTeil:
{
workSheet.Column("A").Width = 2;
workSheet.Column("G").Width = 2;
IXLRange CounterHeaderRange = workSheet.Range("E4:F4").Merge().SetDataType(XLCellValues.Text);
CounterHeaderRange.Value = "Anzahlen";
CounterHeaderRange.Style
.Font.SetBold()
.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Center)
.Alignment.WrapText = true;
int ColumnNumber = 0;
foreach (string Col in ProjektCounterColumns(DistTyp))
workSheet.Cell($"{ColumnNameTable[ColumnNumber++ + 1]}5").Value = Col;
workSheet.Column("D").Width = 40;
return 7;
}
break;
default:
return 7;
}
}
示例5: SplitKD
private static bool SplitKD(IXLWorksheet worksheet, string title, int column)
{
// row to scan for KD
const int row = 6;
try
{
while (!worksheet.Cell(row, column).IsEmpty())
{
// scan for first KD derivative in TRIM LEVEL row
if (worksheet.Cell(row, column).GetString().EndsWith("KD"))
{
// remove existing column grouping - commented out as grouping no longer applied as you can't un-group on a protected worksheet
// worksheet.Columns(8, worksheet.LastColumnUsed().ColumnNumber()).Ungroup();
// add KD SPEC GROUP heading
worksheet.Cell(1, column).Value = title.ToUpper() + " KD";
// insert and size new divider column before KD derivatives
worksheet.Column(column).InsertColumnsBefore(1);
worksheet.Column(column).Width = 8;
// group non-KD derivatives - commented out as you can't un-group on a protected worksheet
// worksheet.Columns(8, column - 1).Group();
// merge non-KD SPEC GROUP heading
worksheet.Range(1, 8, 1, column - 1).Merge();
// group KD derivatives - commented out as you can't un-group on a protected worksheet
// worksheet.Columns(column + 1, worksheet.LastColumnUsed().ColumnNumber()).Group();
// merge KD SPEC GROUP heading
worksheet.Range(1, column + 1, 1, worksheet.LastColumnUsed().ColumnNumber()).Merge();
// add vertical KD title
worksheet.Cell(1, column).Value = title.ToUpper() + " KD";
// merge and format vertical divider heading
worksheet.Range(1, column, 9, column).Merge();
worksheet.Range(1, column, worksheet.LastRowUsed().RowNumber(), column).Style
.Font.SetBold(true)
.Font.SetFontColor(XLColor.White)
.Fill.SetBackgroundColor(XLColor.Black)
.Alignment.SetVertical(XLAlignmentVerticalValues.Bottom)
.Alignment.SetTextRotation(90);
// do for first KD derivative then break out
return true;
}
column = column + 1;
}
return false;
}
catch (Exception ex)
{
Log.Error(ex);
throw;
}
}
示例6: SetRows
private static void SetRows(IXLWorksheet ws)
{
ws.Cell(10, 1).Value = Model.NameOfMaterial;
ws.Cell(20, 43).Value = Model.NameOfMaterial;
var rowCount = Model.ResultTemperaturesModels.Count;
if (rowCount > 1)
{
ws.Row(20).InsertRowsBelow(rowCount - 1);
ws.Range(20, 43, 19 + rowCount, 44).Merge();
ws.Row(10).InsertRowsBelow(rowCount - 1);
ws.Range(10, 1, 9 + rowCount, 1).Merge();
}
}
示例7: createCoverWorksheet
private void createCoverWorksheet(IXLWorksheet worksheet)
{
worksheet.Column("A").Width = 21;
worksheet.Column("B").Width = 26;
worksheet.Cell("A1").Value = "AUDIOVIEW EXPORT";
worksheet.Range("A1","B1").Merge();
addBottomBorder(worksheet.Cell("A1"));
addBottomBorder(worksheet.Cell("B1"));
worksheet.Cell("A2").Value = "PROJECT NAME";
addRightBottomBorder(worksheet.Cell("A2"));
worksheet.Cell("B2").Value = project.Name;
addBottomBorder(worksheet.Cell("B2"));
worksheet.Cell("A3").Value = "PROJECT NUMBER";
addRightBottomBorder(worksheet.Cell("A3"));
worksheet.Cell("B3").Value = project.Number;
addBottomBorder(worksheet.Cell("B3"));
worksheet.Cell("A4").Value = "DATE";
addRightBottomBorder(worksheet.Cell("A4"));
worksheet.Cell("B4").Value = project.Created.ToString();
addBottomBorder(worksheet.Cell("B4"));
worksheet.Cell("A5").Value = "MINOR INTERVAL PERIOD";
addRightBottomBorder(worksheet.Cell("A5"));
worksheet.Cell("B5").Value = project.MinorInterval.ToString();
addBottomBorder(worksheet.Cell("B5"));
worksheet.Cell("A6").Value = "MINOR INTERVAL LIMIT";
addRightBottomBorder(worksheet.Cell("A6"));
worksheet.Cell("B6").Value = project.MinorDBLimit;
addBottomBorder(worksheet.Cell("B6"));
worksheet.Cell("A7").Value = "MAJOR INTERVAL PERIOD";
addRightBottomBorder(worksheet.Cell("A7"));
worksheet.Cell("B7").Value = project.MajorInterval.ToString();
addBottomBorder(worksheet.Cell("B7"));
worksheet.Cell("A8").Value = "MAJOR INTERVAL LIMIT";
addRightBottomBorder(worksheet.Cell("A8"));
worksheet.Cell("B8").Value = project.MajorDBLimit;
addBottomBorder(worksheet.Cell("B8"));
}
示例8: ExpandDescription
public void ExpandDescription(IXLWorksheet ws, IXLRow row)
{
ws.Range(row.Cell((int)CustomsInvoiceHeaders.Description), row.Cell((int)CustomsInvoiceHeaders.Amount)).Merge();
}
示例9: prepDashboardSheets
private void prepDashboardSheets(IXLWorksheet sheet)
{
/*.
* can use htis for both types of sheets.
* Regular: List.Count -1 (end of list: should be Month) List.Count -2 (last value: Should be provider name)
* Diabetes: List.Count -1 (end of list: Month) List.Count -3 (blank space between provider name an dmonth on this one)
*/
_worksheet = sheet;
//use this one to keep track of provider name and row number. then send it to metrics to dashboard and do accordignly
Dictionary<String, IXLRangeRow> providerRows = new Dictionary<String, IXLRangeRow>();
if (_worksheet != null)
{
var firstCell = _worksheet.FirstCellUsed();
var lastCell = _worksheet.LastCellUsed();
_worksheet_range = _worksheet.Range(firstCell.Address, lastCell.Address);
if (_worksheet_range != null)
{
int nRows = _worksheet_range.RowCount();
int nCols = _worksheet_range.ColumnCount();
for (int i = 1; i < nRows + 1; i++)
{
var row = _worksheet_range.Row(i);
var newRow = _worksheet_range.Row(i + 1);
string value = row.Cell(1).Value as string;
if (value != null)
{
foreach (string provider in providers)
{
if (value.Contains(provider))
{
if (_worksheet == _dashboard.Worksheet(2))//add a new row for the depression sheets
{
newRow = _worksheet_range.Row(i + 3);
newRow.InsertRowsBelow(1);
var blankRow = _worksheet_range.Row(i + 4);
blankRow.Style.NumberFormat.NumberFormatId = 0;
providerRows.Add(value, blankRow);
}
else //add a new row for every other sheet in the dashboard: Asthma, Diabetes, Cardiovascular, Preventive
{
newRow = _worksheet_range.Row(i + 2);//this gets us int he right area and then insert the row above
newRow.InsertRowsBelow(1); //try to insert rows after we have metrics and tehn insert metrics into cells then insert row
var blankRow = _worksheet_range.Row(i + 3);
blankRow.Style.NumberFormat.NumberFormatId = 0;
providerRows.Add(value, blankRow);
}
break; //break out of the foreach provider loop, we already found one, we wont find another match, time to go to the next row instead
}
}
}
}
MetricsToDashboard(providerRows, _worksheet);//figure out what we need to send to this method , worksheet, provider / row dict etc.
}
}
}
示例10: OutputOverdues
//.........这里部分代码省略.........
XLColor.DarkRed,
2,
6);
int nRet = 0;
List<IXLCell> cells = new List<IXLCell>();
// 栏目标题
{
List<string> titles = new List<string>();
titles.Add("序号");
titles.Add("册条码号");
titles.Add("书目摘要");
titles.Add("说明");
titles.Add("金额");
titles.Add("ID");
#if NO
titles.Add("以停代金情况");
titles.Add("起点日期");
titles.Add("期限");
titles.Add("终点日期");
#endif
int nColIndex = 2;
foreach (string s in titles)
{
IXLCell cell = sheet.Cell(nRowIndex, nColIndex).SetValue(s);
cell.Style.Alignment.WrapText = true;
cell.Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
cell.Style.Font.Bold = true;
cell.Style.Font.FontColor = XLColor.DarkGray;
nColIndex++;
cells.Add(cell);
}
nRowIndex++;
}
int nItemIndex = 0;
foreach (XmlElement borrow in nodes)
{
string strItemBarcode = borrow.GetAttribute("barcode");
string strReason = borrow.GetAttribute("reason");
string strPrice = borrow.GetAttribute("price");
string strID = borrow.GetAttribute("id");
string strRecPath = borrow.GetAttribute("recPath");
string strSummary = borrow.GetAttribute("summary");
if (string.IsNullOrEmpty(strItemBarcode) == false
&& string.IsNullOrEmpty(strSummary) == true)
{
string strError = "";
nRet = this.MainForm.GetBiblioSummary(strItemBarcode,
strRecPath, // strConfirmItemRecPath,
false,
out strSummary,
out strError);
if (nRet == -1)
strSummary = strError;
}
List<string> cols = new List<string>();
cols.Add((nItemIndex + 1).ToString());
cols.Add(strItemBarcode);
cols.Add(strSummary);
cols.Add(strReason);
cols.Add(strPrice);
cols.Add(strID);
int nColIndex = 2;
foreach (string s in cols)
{
// 统计最大字符数
SetMaxChars(ref column_max_chars, nColIndex - 1, GetCharWidth(s));
IXLCell cell = null;
if (nColIndex == 2)
{
cell = sheet.Cell(nRowIndex, nColIndex).SetValue(nItemIndex + 1);
cell.Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
}
else
cell = sheet.Cell(nRowIndex, nColIndex).SetValue(s);
cell.Style.Alignment.WrapText = true;
cell.Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
nColIndex++;
cells.Add(cell);
}
nItemIndex++;
nRowIndex++;
}
// 标题行下的虚线
var rngData = sheet.Range(cells[0], cells[cells.Count - 1]);
rngData.FirstRow().Style.Border.TopBorder = XLBorderStyleValues.Dotted;
sheet.Rows(nStartRow + 1, nRowIndex - 1).Group();
}
示例11: OutputBorrows
//.........这里部分代码省略.........
titles.Add("借期");
titles.Add("应还时间");
titles.Add("是否超期");
int nColIndex = 2;
foreach (string s in titles)
{
IXLCell cell = sheet.Cell(nRowIndex, nColIndex).SetValue(s);
cell.Style.Alignment.WrapText = true;
cell.Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
cell.Style.Font.Bold = true;
cell.Style.Font.FontColor = XLColor.DarkGray;
//cell.Style.Font.FontName = strFontName;
//cell.Style.Alignment.Horizontal = alignments[nColIndex - 1];
nColIndex++;
cells.Add(cell);
}
nRowIndex++;
}
int nItemIndex = 0;
foreach (XmlElement borrow in nodes)
{
string strItemBarcode = borrow.GetAttribute("barcode");
string strBorrowDate = ToLocalTime(borrow.GetAttribute("borrowDate"), "yyyy-MM-dd HH:mm");
string strBorrowPeriod = GetDisplayTimePeriodString(borrow.GetAttribute("borrowPeriod"));
string strReturningDate = ToLocalTime(borrow.GetAttribute("returningDate"), "yyyy-MM-dd");
string strRecPath = borrow.GetAttribute("recPath");
string strIsOverdue = borrow.GetAttribute("isOverdue");
bool bIsOverdue = DomUtil.IsBooleanTrue(strIsOverdue, false);
string strOverdueInfo = borrow.GetAttribute("overdueInfo1");
string strSummary = borrow.GetAttribute("summary");
#if NO
nRet = this.MainForm.GetBiblioSummary(strItemBarcode,
strRecPath, // strConfirmItemRecPath,
false,
out strSummary,
out strError);
if (nRet == -1)
strSummary = strError;
#endif
List<string> cols = new List<string>();
cols.Add((nItemIndex + 1).ToString());
cols.Add(strItemBarcode);
cols.Add(strSummary);
cols.Add(strBorrowDate);
cols.Add(strBorrowPeriod);
cols.Add(strReturningDate);
if (bIsOverdue)
cols.Add(strOverdueInfo);
else
cols.Add("");
int nColIndex = 2;
foreach (string s in cols)
{
// 统计最大字符数
SetMaxChars(ref column_max_chars, nColIndex - 1, GetCharWidth(s));
IXLCell cell = null;
if (nColIndex == 2)
{
cell = sheet.Cell(nRowIndex, nColIndex).SetValue(nItemIndex + 1);
cell.Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
}
else
cell = sheet.Cell(nRowIndex, nColIndex).SetValue(s);
cell.Style.Alignment.WrapText = true;
cell.Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
//cell.Style.Font.FontName = strFontName;
//cell.Style.Alignment.Horizontal = alignments[nColIndex - 1];
nColIndex++;
cells.Add(cell);
}
// 超期的行为黄色背景
if (bIsOverdue)
{
var line = sheet.Range(nRowIndex, 2, nRowIndex, 2 + cols.Count - 1);
line.Style.Fill.BackgroundColor = XLColor.Yellow;
}
nItemIndex++;
nRowIndex++;
}
// 册信息标题下的虚线
var rngData = sheet.Range(cells[0], cells[cells.Count - 1]);
rngData.FirstRow().Style.Border.TopBorder = XLBorderStyleValues.Dotted;
#if NO
// 第一行上面的横线
rngData = sheet.Range(cell_no, cells[cells.Count - 1]);
rngData.FirstRow().Style.Border.TopBorder = XLBorderStyleValues.Medium;
#endif
sheet.Rows(nStartRow + 1, nRowIndex-1).Group();
}
示例12: OutputReaderInfo
void OutputReaderInfo(IXLWorksheet sheet,
XmlDocument dom,
int nReaderIndex,
ref int nRowIndex,
ref List<int> column_max_chars)
{
string strReaderBarcode = DomUtil.GetElementText(dom.DocumentElement,
"barcode");
string strName = DomUtil.GetElementText(dom.DocumentElement,
"name");
string strDepartment = DomUtil.GetElementText(dom.DocumentElement,
"department");
string strState = DomUtil.GetElementText(dom.DocumentElement,
"state");
string strCreateDate = ToLocalTime(DomUtil.GetElementText(dom.DocumentElement,
"createDate"), "yyyy/MM/dd");
string strExpireDate = ToLocalTime(DomUtil.GetElementText(dom.DocumentElement,
"expireDate"), "yyyy/MM/dd");
string strReaderType = DomUtil.GetElementText(dom.DocumentElement,
"readerType");
string strComment = DomUtil.GetElementText(dom.DocumentElement,
"comment");
List<IXLCell> cells = new List<IXLCell>();
// 读者序号
// IXLCell cell_no = null;
int nColIndex = 2;
{
IXLCell cell = sheet.Cell(nRowIndex, nColIndex).SetValue(nReaderIndex + 1);
cell.Style.Alignment.WrapText = true;
cell.Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
cell.Style.Font.Bold = true;
cell.Style.Font.FontSize = 20;
//cell.Style.Font.FontName = strFontName;
//cell.Style.Alignment.Horizontal = alignments[nColIndex - 1];
// cell.Style.Fill.BackgroundColor = XLColor.LightGray;
cells.Add(cell);
// cell_no = cell;
nColIndex++;
}
// 最大字符数
SetMaxChars(ref column_max_chars, 1, (nReaderIndex + 1).ToString().Length * 2);
// 序号的右边竖线
{
var rngData = sheet.Range(nRowIndex, 2, nRowIndex + 3, 2);
rngData.Merge();
rngData.LastColumn().Style.Border.RightBorder = XLBorderStyleValues.Hair;
// 第一行上面的横线
rngData = sheet.Range(nRowIndex, 2, nRowIndex, 2 + 7 - 1);
rngData.FirstRow().Style.Border.TopBorder = XLBorderStyleValues.Medium;
}
#if NO
// 特殊状态时的整个底色
if (string.IsNullOrEmpty(strState) == false)
{
var rngData = sheet.Range(nRowIndex, 2, nRowIndex + 3, 2 + 7 - 1);
rngData.Style.Fill.BackgroundColor = XLColor.LightBrown;
}
#endif
int nFirstRow = nRowIndex;
{
List<string> subtitles = new List<string>();
subtitles.Add("姓名");
subtitles.Add("证条码号");
subtitles.Add("部门");
subtitles.Add("联系方式");
List<string> subcols = new List<string>();
subcols.Add(strName);
subcols.Add(strReaderBarcode);
subcols.Add(strDepartment);
subcols.Add(GetContactString(dom));
for (int line = 0; line < subtitles.Count; line++)
{
nColIndex = 3;
{
IXLCell cell = sheet.Cell(nRowIndex, nColIndex).SetValue(subtitles[line]);
cell.Style.Alignment.WrapText = true;
cell.Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
cell.Style.Font.Bold = true;
cell.Style.Font.FontColor = XLColor.DarkGray;
//cell.Style.Font.FontName = strFontName;
cell.Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
// cell.Style.Fill.BackgroundColor = XLColor.LightGray;
nColIndex++;
cells.Add(cell);
}
{
IXLCell cell = sheet.Cell(nRowIndex, nColIndex).SetValue(subcols[line]);
cell.Style.Alignment.WrapText = true;
cell.Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
//cell.Style.Font.FontName = strFontName;
//.........这里部分代码省略.........
示例13: OutputTitleLine
static void OutputTitleLine(IXLWorksheet sheet,
ref int nRowIndex,
string strTitle,
XLColor text_color,
int nStartIndex,
int nColumnCount)
{
// 读者序号
int nColIndex = nStartIndex;
{
IXLCell cell = sheet.Cell(nRowIndex, nColIndex).SetValue(strTitle);
cell.Style.Alignment.WrapText = true;
cell.Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
cell.Style.Font.Bold = true;
cell.Style.Font.FontColor = text_color;
//cell.Style.Font.FontName = strFontName;
cell.Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
// cell.Style.Fill.BackgroundColor = XLColor.LightGray;
nColIndex++;
}
// 合并格子
{
var rngData = sheet.Range(nRowIndex, nStartIndex, nRowIndex, nStartIndex + nColumnCount - 1);
rngData.Merge();
// rngData.LastColumn().Style.Border.RightBorder = XLBorderStyleValues.Hair;
}
nRowIndex++;
}
示例14: OutputBorrowHistory
//.........这里部分代码省略.........
ChargingItem item = wrapper.Item;
ChargingItem rel = wrapper.RelatedItem;
string strItemBarcode = item.ItemBarcode;
string strBorrowDate = rel == null ? "" : rel.OperTime;
string strBorrowPeriod = GetDisplayTimePeriodString(rel == null ? "" : rel.Period);
string strReturnDate = item.OperTime;
//string strRecPath = borrow.GetAttribute("recPath");
//string strIsOverdue = borrow.GetAttribute("isOverdue");
//bool bIsOverdue = DomUtil.IsBooleanTrue(strIsOverdue, false);
//string strOverdueInfo = borrow.GetAttribute("overdueInfo1");
string strSummary = "";
#if NO
if (string.IsNullOrEmpty(strItemBarcode) == false
&& string.IsNullOrEmpty(strSummary) == true)
{
string strError = "";
int nRet = procGetBiblioSummary(strItemBarcode,
"", // strConfirmItemRecPath,
false,
out strSummary,
out strError);
if (nRet == -1)
strSummary = strError;
}
#endif
item_barcodes.Add("@itemBarcode:" + strItemBarcode);
List<string> cols = new List<string>();
cols.Add((nItemIndex + 1).ToString());
cols.Add(strItemBarcode);
cols.Add(strSummary);
cols.Add(strBorrowDate);
cols.Add(strBorrowPeriod);
cols.Add(rel == null ? "" : rel.Operator);
cols.Add(strReturnDate);
cols.Add(item.Operator);
int nColIndex = 2;
points.Add(new Point(nColIndex + 2, nRowIndex));
foreach (string s in cols)
{
// 统计最大字符数
SetMaxChars(ref column_max_chars, nColIndex - 1, GetCharWidth(s));
IXLCell cell = null;
if (nColIndex == 2)
{
cell = sheet.Cell(nRowIndex, nColIndex).SetValue(nItemIndex + 1);
cell.Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
}
else
cell = sheet.Cell(nRowIndex, nColIndex).SetValue(s);
cell.Style.Alignment.WrapText = true;
cell.Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
//cell.Style.Font.FontName = strFontName;
//cell.Style.Alignment.Horizontal = alignments[nColIndex - 1];
nColIndex++;
cells.Add(cell);
}
#if NO
// 超期的行为黄色背景
if (bIsOverdue)
{
var line = sheet.Range(nRowIndex, 2, nRowIndex, 2 + cols.Count - 1);
line.Style.Fill.BackgroundColor = XLColor.Yellow;
}
#endif
nItemIndex++;
nRowIndex++;
}
// 加入书目摘要
summary_loader.RecPaths = item_barcodes;
int i = 0;
foreach (BiblioItem biblio in summary_loader)
{
Point point = points[i];
int nColIndex = point.X;
// 统计最大字符数
SetMaxChars(ref column_max_chars, nColIndex - 1, GetCharWidth(biblio.Content));
IXLCell cell = null;
cell = sheet.Cell(point.Y, nColIndex).SetValue(biblio.Content);
cell.Style.Alignment.WrapText = true;
cell.Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
i++;
}
// 册信息标题下的虚线
var rngData = sheet.Range(cells[0], cells[cells.Count - 1]);
rngData.FirstRow().Style.Border.TopBorder = XLBorderStyleValues.Dotted;
sheet.Rows(nStartRow + 1, nRowIndex - 1).Group();
}
示例15: BuildTextPageTop
// 构造表格标题和标题行
int BuildTextPageTop(PrintOption option,
Hashtable macro_table,
StreamWriter sw,
// ref ExcelDocument doc
IXLWorksheet sheet
)
{
// 表格标题
string strTableTitleText = option.TableTitle;
if (String.IsNullOrEmpty(strTableTitleText) == false)
{
strTableTitleText = StringUtil.MacroString(macro_table,
strTableTitleText);
if (sw != null)
{
sw.WriteLine(strTableTitleText);
sw.WriteLine("");
}
if (sheet != null)
{
#if NO
doc.WriteExcelTitle(0,
option.Columns.Count, // nTitleCols,
strTableTitleText,
6);
#endif
var header = sheet.Range(1, 1,
1, option.Columns.Count).Merge();
header.Value = strTableTitleText;
header.Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
// header.Style.Font.FontName = "微软雅黑";
header.Style.Font.Bold = true;
header.Style.Font.FontSize = 16;
}
}
string strColumnTitleLine = "";
List<int> widths = new List<int>();
for (int i = 0; i < option.Columns.Count; i++)
{
Column column = option.Columns[i];
widths.Add(column.WidthChars);
string strCaption = column.Caption;
// 如果没有caption定义,就挪用name定义
if (String.IsNullOrEmpty(strCaption) == true)
strCaption = column.Name;
// string strClass = Global.GetLeft(column.Name);
if (i != 0)
strColumnTitleLine += "\t";
strColumnTitleLine += strCaption;
if (sheet != null)
{
#if NO
doc.WriteExcelCell(
2,
i,
strCaption,
true);
#endif
var cell = sheet.Cell(2+1, i+1);
cell.Value = strCaption;
// cell.Style.Font.FontName = "微软雅黑";
cell.Style.Font.Bold = true;
if (column.WidthChars != -1)
sheet.Column(i + 1).Width = column.WidthChars;
}
}
if (sw != null)
sw.WriteLine(strColumnTitleLine);
#if NO
if (doc != null)
SetColumnWidth(doc, widths);
#endif
return 0;
}