本文整理汇总了C#中XlsFile.MergeCells方法的典型用法代码示例。如果您正苦于以下问题:C# XlsFile.MergeCells方法的具体用法?C# XlsFile.MergeCells怎么用?C# XlsFile.MergeCells使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XlsFile
的用法示例。
在下文中一共展示了XlsFile.MergeCells方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateSpreadsheet
void CreateSpreadsheet()
{
var locations = LocationHelper.Instance.Locations;
var xls = new XlsFile (1, true);
xls.SetCellValue (1, 1, "Location data from Xamarin.iOS");
xls.SetCellValue (2, 1, "Latitude");
xls.SetCellValue (2, 2, "Longitude");
xls.SetCellValue (2, 3, "Altitude");
int row = 2;
xls.MergeCells(1, 1, 1, 3);
SetTitleCellFormat (xls);
locations.ForEach (l => {
xls.SetCellValue (++row, 1, l.Coordinate.Latitude);
xls.SetCellValue (row, 2, l.Coordinate.Longitude);
xls.SetCellValue (row, 3, l.Altitude);
});
xls.Save (path);
}
示例2: MergeCells
/// <summary>
///
/// </summary>
/// <param name="xls"></param>
/// <param name="area"></param>
internal void MergeCells(XlsFile xls, Rectangle area)
{
xls.MergeCells(area.Top, area.Left, area.Bottom-1, area.Right-1);
xls.SetCellFormat(area.Top, area.Left, area.Bottom - 1, area.Right - 1,
GetMergedCellFormat(xls));
}
示例3: Report_3
public void Report_3(IEnumerable<GetReport3_Levy_Products_Result> daily_trans, string filterType, string exchange_rate, string typ)
{
//var bK = daily_trans;
//if (bK.Count() <= 0)
//{
// TempData["Warning"] = "No Data To Export";
// return;
//}
string Orginal_file_path = string.Empty;
if (typ.Equals("pdf"))
Orginal_file_path = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("~/Report_Templates"), "Report_3_B.xlsx");
else
Orginal_file_path = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("~/Report_Templates"), "Report_3_A.xlsx");
//temp file name
string copy_file_name = DateTime.Now.Ticks + ".xlsx";
//temp file path
string copy_file_path = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("~/Images"), copy_file_name);
//copy to temp destination
XlsFile report_3 = new XlsFile(Orginal_file_path);
int c = 0;
if (!typ.Equals("pdf"))
c = 1;
report_3.ActiveSheet = 1;
report_3.SetCellValue(3, 3 + c, GetDecimal(exchange_rate));
report_3.SetCellValue(2, 1 + c, filterType);
//get color 1
int col1 = report_3.AddFormat(GetColor1(report_3.GetCellVisibleFormatDef(6, 2)));
//get colo1 2
int col2 = report_3.AddFormat(GetColor2(report_3.GetCellVisibleFormatDef(6, 2)));
int style = col1;
int i = 6;
string category_1 = string.Empty;
int dataExist = 0;
int j = 0;
foreach (var item in daily_trans)
{
dataExist = 1;
if (i != 6 && category_1.Equals(item.Category_Name))
report_3.MergeCells(i - 1, 1, i, 1);
else
{
if (style == col1)
style = col2;
else
style = col1;
}
//style = res_arr[j];
category_1 = item.Category_Name;
report_3.SetCellValue(i, 1 + c, item.Category_Name, style);
if (item.Goods_Name.Equals("All"))
{
//get current style and add bold
TFlxFormat tformat = GetBold(report_3.GetCellVisibleFormatDef(i, 1 + c));
int res2 = report_3.AddFormat(tformat);
//end style modification
report_3.SetCellValue(i, 2 + c, item.Goods_Name, res2);
report_3.SetCellValue(i, 3 + c, item.Unit, res2);
report_3.SetCellValue(i, 4 + c, item.Total_Quantity, res2);
report_3.SetCellValue(i, 5 + c, item.Total_Amount_in_SOS, res2);
report_3.SetCellValue(i, 6 + c, item.Total_Amount_in_USD, res2);
}
else
{
report_3.SetCellValue(i, 2 + c, item.Goods_Name, style);
report_3.SetCellValue(i, 3 + c, item.Unit, style);
report_3.SetCellValue(i, 4 + c, item.Total_Quantity, style);
report_3.SetCellValue(i, 5 + c, item.Total_Amount_in_SOS, style);
report_3.SetCellValue(i, 6 + c, item.Total_Amount_in_USD, style);
}
i++;
}
if (dataExist <= 0)
{
TempData["Warning"] = "No Data To Export";
//.........这里部分代码省略.........
示例4: TaoTieuDe
//.........这里部分代码省略.........
ColFmt = xls.GetFormat(xls.GetColFormat(8));
ColFmt.Font.Name = "Times New Roman";
ColFmt.Font.Family = 1;
ColFmt.Font.CharSet = 0;
xls.SetColFormat(8, xls.AddFormat(ColFmt));
xls.SetColWidth(9, 4059); //(15.11 + 0.75) * 256
ColFmt = xls.GetFormat(xls.GetColFormat(9));
ColFmt.Font.Name = "Times New Roman";
ColFmt.Font.Family = 1;
ColFmt.Font.CharSet = 0;
xls.SetColFormat(9, xls.AddFormat(ColFmt));
#endregion
#region set độ rộng cột
for (int c = 0; c < TongSoCot + SoTrang; c++)
{
ColFmt = xls.GetFormat(xls.GetColFormat(c + TuCot));
ColFmt.Font.Name = "Times New Roman";
ColFmt.Font.Family = 1;
ColFmt.Font.CharSet = 0;
xls.SetColFormat(c + TuCot, xls.AddFormat(ColFmt));
xls.SetColWidth(c + TuCot + 1, 4059);
}
#endregion
xls.DefaultRowHeight = 300;
xls.SetRowHeight(7, 1545);
xls.SetRowHeight(8, 360);
#region //Merged Cells
xls.MergeCells(6, 1, 7, 1);
xls.MergeCells(6, 3, 7, 3);
xls.MergeCells(6, 4, 6, 9);
xls.MergeCells(5, 1, 5, 2);
xls.MergeCells(1, 1, 1, 2);
xls.MergeCells(1, 3, 1, 9);
xls.MergeCells(2, 3, 2, 9);
for (int t = 0; t < SoTrang; t++)
{
xls.MergeCells(6, _C, 6, _C + SoCotCuaMotTrang-1);
_C = _C + SoCotCuaMotTrang;
}
#endregion
//Set the cell values
TFlxFormat fmt;
#region
fmt = xls.GetCellVisibleFormatDef(1, 1);
fmt.Font.Name = "Times New Roman";
fmt.Font.Style = TFlxFontStyles.Bold;
fmt.Font.Family = 1;
fmt.Font.CharSet = 0;
fmt.HAlignment = THFlxAlignment.left;
xls.SetCellFormat(1, 1, xls.AddFormat(fmt));
xls.SetCellValue(1, 1, "BỘ QUỐC PHÒNG");
fmt = xls.GetCellVisibleFormatDef(1, 3);
fmt.Font.Name = "Times New Roman";
fmt.Font.Style = TFlxFontStyles.Bold;
fmt.Font.Family = 1;
fmt.Font.CharSet = 0;
示例5: TaoTieuDe
//.........这里部分代码省略.........
fmt.Borders.Left.Color = TExcelColor.Automatic;
fmt.Borders.Right.Style = TFlxBorderStyle.Thin;
fmt.Borders.Right.Color = TExcelColor.Automatic;
fmt.Borders.Top.Style = TFlxBorderStyle.Thin;
fmt.Borders.Top.Color = TExcelColor.Automatic;
fmt.Borders.Bottom.Style = TFlxBorderStyle.Thin;
fmt.Borders.Bottom.Color = TExcelColor.Automatic;
fmt.HAlignment = THFlxAlignment.center;
fmt.VAlignment = TVFlxAlignment.center;
fmt.WrapText = true;
xls.SetCellFormat(4, 9, xls.AddFormat(fmt));
xls.SetCellValue(4, 9, 6);
fmt = xls.GetCellVisibleFormatDef(4, 10);
fmt.Font.Name = "Times New Roman";
fmt.Font.Family = 1;
fmt.Borders.Left.Style = TFlxBorderStyle.Thin;
fmt.Borders.Left.Color = TExcelColor.Automatic;
fmt.Borders.Right.Style = TFlxBorderStyle.Thin;
fmt.Borders.Right.Color = TExcelColor.Automatic;
fmt.Borders.Top.Style = TFlxBorderStyle.Thin;
fmt.Borders.Top.Color = TExcelColor.Automatic;
fmt.Borders.Bottom.Style = TFlxBorderStyle.Thin;
fmt.Borders.Bottom.Color = TExcelColor.Automatic;
fmt.HAlignment = THFlxAlignment.center;
fmt.VAlignment = TVFlxAlignment.center;
fmt.WrapText = true;
xls.SetCellFormat(4, 10, xls.AddFormat(fmt));
xls.SetCellValue(4, 10, 7);
#endregion
#region cau hinh chu ku
xls.MergeCells(TongSoHang + TuHang + 4, 1, TongSoHang + TuHang + 4, 2);
xls.MergeCells(TongSoHang + TuHang + 4, 3, TongSoHang + TuHang + 4, 4);
xls.MergeCells(TongSoHang + TuHang + 4, 5, TongSoHang + TuHang + 4, 6);
xls.MergeCells(TongSoHang + TuHang +4, 7, TongSoHang + TuHang + 4, 8);
xls.MergeCells(TongSoHang + TuHang + 4, 9, TongSoHang + TuHang + 4, 10);
// Thua lenh - chuc danh - ten
fmt = xls.GetCellVisibleFormatDef(TongSoHang + TuHang + 4, 1);
fmt.Font.Name = "Times New Roman";
fmt.Font.Size20 = 220;
fmt.Font.Family = 1;
fmt.HAlignment = THFlxAlignment.center;
fmt.VAlignment = TVFlxAlignment.center;
fmt.WrapText = true;
xls.SetCellFormat(TongSoHang + TuHang + 4, 1, xls.AddFormat(fmt));
xls.SetCellValue(TongSoHang + TuHang + 4, 1, "<#row height(autofit)><#ThuaLenh1> \n<#ChucDanh1>\n\n\n\n\n\n\n<#Ten1>");
fmt = xls.GetCellVisibleFormatDef(TongSoHang + TuHang +4, 3);
fmt.Font.Name = "Times New Roman";
fmt.Font.Size20 = 220;
fmt.Font.Family = 1;
fmt.HAlignment = THFlxAlignment.center;
fmt.VAlignment = TVFlxAlignment.center;
fmt.WrapText = true;
xls.SetCellFormat(TongSoHang + TuHang + 4, 3, xls.AddFormat(fmt));
xls.SetCellValue(TongSoHang + TuHang + 4, 3, "<#row height(autofit)><#ThuaLenh2> \n<#ChucDanh2>\n\n\n\n\n\n\n<#Ten2>");
fmt = xls.GetCellVisibleFormatDef(TongSoHang + TuHang + 4, 5);
fmt.Font.Name = "Times New Roman";
fmt.Font.Size20 = 220;
fmt.Font.Family = 1;
fmt.HAlignment = THFlxAlignment.center;
fmt.VAlignment = TVFlxAlignment.center;
fmt.WrapText = true;
示例6: TaoTieuDe
//.........这里部分代码省略.........
xls.SetColFormat(251, xls.AddFormat(ColFmt));
ColFmt = xls.GetFormat(xls.GetColFormat(252));
ColFmt.Font.Name = "Times New Roman";
ColFmt.Font.Family = 1;
xls.SetColFormat(252, xls.AddFormat(ColFmt));
ColFmt = xls.GetFormat(xls.GetColFormat(253));
ColFmt.Font.Name = "Times New Roman";
ColFmt.Font.Family = 1;
xls.SetColFormat(253, xls.AddFormat(ColFmt));
ColFmt = xls.GetFormat(xls.GetColFormat(254));
ColFmt.Font.Name = "Times New Roman";
ColFmt.Font.Family = 1;
xls.SetColFormat(254, xls.AddFormat(ColFmt));
ColFmt = xls.GetFormat(xls.GetColFormat(255));
ColFmt.Font.Name = "Times New Roman";
ColFmt.Font.Family = 1;
xls.SetColFormat(255, xls.AddFormat(ColFmt));
ColFmt = xls.GetFormat(xls.GetColFormat(256));
ColFmt.Font.Name = "Times New Roman";
ColFmt.Font.Family = 1;
xls.SetColFormat(256, xls.AddFormat(ColFmt));
xls.DefaultRowHeight = 300;
xls.SetRowHeight(1, 330); //16.50 * 20
xls.SetRowHeight(2, 315); //15.75 * 20
xls.SetRowHeight(4, 390); //19.50 * 20
//Merged Cells
xls.MergeCells(3, 3, 3, 5);
xls.MergeCells(1, 1, 1, 6);
xls.MergeCells(2, 1, 2, 6);
xls.MergeCells(2, 3, 2, 5);
//Set the cell values
TFlxFormat fmt;
fmt = xls.GetCellVisibleFormatDef(1, 1);
fmt.Font.Name = "Times New Roman";
fmt.Font.Size20 = 280;
fmt.Font.Family = 1;
fmt.Font.Style = TFlxFontStyles.Bold;
fmt.HAlignment = THFlxAlignment.center;
fmt.VAlignment = TVFlxAlignment.center;
xls.SetCellFormat(1, 1, xls.AddFormat(fmt));
xls.SetCellValue(1, 1, "DANH SÁCH CHI TRẢ CÁ NHÂN");
fmt = xls.GetCellVisibleFormatDef(1, 2);
fmt.Font.Name = "Times New Roman";
fmt.Font.Size20 = 240;
fmt.Font.Family = 1;
fmt.HAlignment = THFlxAlignment.left;
fmt.VAlignment = TVFlxAlignment.center;
xls.SetCellFormat(1, 2, xls.AddFormat(fmt));
fmt = xls.GetCellVisibleFormatDef(1, 3);
fmt.Font.Name = "Times New Roman";
fmt.Font.Size20 = 260;
fmt.Font.Style = TFlxFontStyles.Bold;
fmt.Font.Family = 1;
fmt.VAlignment = TVFlxAlignment.center;
xls.SetCellFormat(1, 3, xls.AddFormat(fmt));
示例7: FillData
/// <summary>
/// Đổ dữ liệu xuống báo cáo
/// </summary>
/// <param name="xls"></param>
/// <param name="dt"></param>
/// <param name="DK1"></param>
/// <param name="DK2"></param>
/// <param name="DK3"></param>
public void FillData(XlsFile xls, DataTable dt, String DK1, String DK2, String DK3)
{
TFlxFormat fmt, fmt1,fmt2,fmt_TL,fmt_CD,fmt_Ten;
Object GiaTriO;
int sohang = 45;
int sotrang = 1;
///Fill nửa bên trái
for (int i = 0; i < dt.Rows.Count; i = i + sohang)
{
i = i + sohang;
#region "Fill nửa bên trái"
for (int j = i - sohang; j < i; j++)
{
if ((j + i - sohang) < dt.Rows.Count)
{
for (int c = 0; c < 3; c++)
{
fmt = xls.GetCellVisibleFormatDef(5 + j + i - sohang * sotrang, c + 1);
fmt.Font.Name = "Times New Roman";
fmt.Font.Size20 = 200;
fmt.Font.Family = 1;
fmt.VAlignment = TVFlxAlignment.center;
fmt.WrapText = true;
xls.DefaultRowHeight = 300;
xls.AutofitRow(5 + j + i - sohang * sotrang, true, 1);
GiaTriO = null;
if (Convert.ToString(dt.Rows[j + i - sohang][DK1].ToString()) == ""
&& Convert.ToString(dt.Rows[j + i - sohang][DK2].ToString()) != ""
&& Convert.ToString(dt.Rows[j + i - sohang][DK3].ToString())=="")
{
fmt.Font.Style = TFlxFontStyles.Bold;
fmt.Font.Family = 1;
fmt.Borders.Top.Style = TFlxBorderStyle.Thin;
fmt.Borders.Top.Color = TExcelColor.Automatic;
fmt.Borders.Bottom.Style = TFlxBorderStyle.Thin;
fmt.Borders.Bottom.Color = TExcelColor.Automatic;
if (c == 0)
{
fmt.Borders.Left.Style = TFlxBorderStyle.Thin;
fmt.Borders.Right.Style = TFlxBorderStyle.None;
GiaTriO = dt.Rows[j + i - sohang][c+1];
}
else
{
fmt.Borders.Left.Style = TFlxBorderStyle.None;
fmt.Borders.Right.Style = TFlxBorderStyle.Thin;
GiaTriO = dt.Rows[j + i - sohang][c];
}
xls.MergeCells(5 + j + i - sohang * sotrang, 1, 5 + j + i - sohang * sotrang, 3);
xls.SetCellFormat(5 + j + i - sohang * sotrang, c +1, xls.AddFormat(fmt));
xls.SetCellValue(5 + j + i - sohang * sotrang, c +1, GiaTriO);
}
else if (Convert.ToString(dt.Rows[j + i - sohang][DK1].ToString()) == ""
&& Convert.ToString(dt.Rows[j + i - sohang][DK2].ToString()) == "+"
&& Convert.ToString(dt.Rows[j + i - sohang][DK3].ToString()) != "")
{
fmt.Font.Style = TFlxFontStyles.Bold;
fmt.HAlignment = THFlxAlignment.center;
fmt.Borders.Top.Color = TExcelColor.Automatic;
fmt.Borders.Bottom.Style = TFlxBorderStyle.Thin;
fmt.Borders.Right.Style = TFlxBorderStyle.Thin;
fmt.Borders.Left.Style = TFlxBorderStyle.Thin;
fmt.Borders.Top.Style = TFlxBorderStyle.Thin;
fmt.Borders.Bottom.Color = TExcelColor.Automatic;
fmt.Format = "_(* #,##0_);_(* \\-#,##0_);_(* \"\"_);_(@_)";
xls.MergeCells(5 + j + i - sohang * sotrang, 1, 5 + j + i - sohang * sotrang, 2);
if(c==0)
GiaTriO = dt.Rows[j + i - sohang][c+1];
else
GiaTriO = dt.Rows[j + i - sohang][c];
xls.SetCellFormat(5 + j + i - sohang * sotrang, c + 1, xls.AddFormat(fmt));
xls.SetCellValue(5 + j + i - sohang * sotrang, c + 1, GiaTriO);
}
else if (Convert.ToString(dt.Rows[j + i - sohang][DK1].ToString()) != ""
&& Convert.ToString(dt.Rows[j + i - sohang][DK2].ToString()) != "+"
&& Convert.ToString(dt.Rows[j + i - sohang][DK3].ToString()) != "")
{
fmt.Font.Style = TFlxFontStyles.None;
fmt.Font.Family = 1;
fmt.Borders.Top.Color = TExcelColor.Automatic;
fmt.Borders.Right.Style = TFlxBorderStyle.Thin;
fmt.Borders.Left.Style = TFlxBorderStyle.Thin;
fmt.Borders.Bottom.Color = TExcelColor.Automatic;
fmt.Borders.Bottom.Style = TFlxBorderStyle.Dotted;
switch(c)
{
case 0:
if (DK1 == "TT_DV")
{
fmt.HAlignment = THFlxAlignment.center;
}
//.........这里部分代码省略.........
示例8: TaoTieuDe_A3
//.........这里部分代码省略.........
ColFmt.Font.Name = "Times New Roman";
ColFmt.Font.Family = 1;
xls.SetColFormat(4, xls.AddFormat(ColFmt));
xls.SetColWidth(5, 900); //(2.82 + 0.75) * 256
ColFmt = xls.GetFormat(xls.GetColFormat(5));
ColFmt.Font.Name = "Times New Roman";
ColFmt.Font.Family = 1;
xls.SetColFormat(5, xls.AddFormat(ColFmt));
xls.SetColWidth(6, 800); //(2.39 + 0.75) * 256
ColFmt = xls.GetFormat(xls.GetColFormat(6));
ColFmt.Font.Name = "Times New Roman";
ColFmt.Font.Family = 1;
xls.SetColFormat(6, xls.AddFormat(ColFmt));
xls.SetColWidth(7, 8000); //(27.68 + 0.75) * 256
ColFmt = xls.GetFormat(xls.GetColFormat(7));
ColFmt.Font.Name = "Times New Roman";
ColFmt.Font.Family = 1;
xls.SetColFormat(7, xls.AddFormat(ColFmt));
xls.SetColWidth(8, 3400); //(12.39 + 0.75) * 256
for (int i = 0; i < TongSoCot; i++)
{
xls.SetColWidth(_TuCot + i, 3400);
}
xls.SetRowHeight(4, 600);
xls.SetRowHeight(5, 600);
xls.DefaultRowHeight = 300;
#endregion
#region//Merged Cells
xls.MergeCells(4, 1, 5, 6);
xls.MergeCells(4, 7, 5, 7);
xls.MergeCells(4, 8, 5, 8);
_TuCot = TuCot;
if (SoTrang == 1)
{
xls.MergeCells(4, _TuCot, 4, _TuCot + SoCotTrang1 - 1);
}
else
{
xls.MergeCells(4, _TuCot, 4, _TuCot + SoCotTrang1 - 1);
_TuCot = _TuCot + SoCotTrang1;
for (int i = 1; i < SoTrang; i++)
{
xls.MergeCells(4, _TuCot, 4, _TuCot + SoCotTrangLonHon1 - 1);
_TuCot = _TuCot + SoCotTrangLonHon1;
}
}
#endregion
#region //Set the cell values
#region set tieu de cot tinh
TFlxFormat fmt;
fmt = xls.GetCellVisibleFormatDef(1, 1);
fmt.Font.Name = "Times New Roman";
fmt.Font.Style = TFlxFontStyles.Bold;
fmt.Font.Family = 1;
fmt.HAlignment = THFlxAlignment.center;
fmt.VAlignment = TVFlxAlignment.center;
xls.SetCellFormat(1, 1, xls.AddFormat(fmt));
xls.SetCellValue(1, 1, "<#auto page breaks>");
fmt = xls.GetCellVisibleFormatDef(4, 1);