本文整理汇总了C#中XlsFile.NewFile方法的典型用法代码示例。如果您正苦于以下问题:C# XlsFile.NewFile方法的具体用法?C# XlsFile.NewFile怎么用?C# XlsFile.NewFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XlsFile
的用法示例。
在下文中一共展示了XlsFile.NewFile方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Export
/// <summary>
///
/// </summary>
internal override void Export()
{
_xls = new XlsFile();
//_xls.Open(_xlsPath);
_xls.NewFile (1);
SetCellValue(_xls, Config.TitleArea,
string.Format(ReportStrings.Title, B, E), false);
MergeCells(_xls, Config.TitleArea);
// set first column names
//
int row = ExportFirst(5);
ExportStations(row);
string filename = Xdgk.Common.Path.GetTempFileName("xls");
_xls.Save(filename);
Open(filename);
}
示例2: WriteSerializationResult
public void WriteSerializationResult( Stream stream )
{
XlsFile xlsFile = new XlsFile(true);
DataTableCollection tables = ResultDataSet.Tables;
// создать новый XLS-файл
xlsFile.NewFile( tables.Count );
// записать в файл содержимое каждой таблицы
for (int tableIndex = 0; tableIndex < tables.Count; ++tableIndex)
{
// установить текущий лист
xlsFile.ActiveSheet = tableIndex + 1;
WriteDataTable( tables[tableIndex], xlsFile );
}
// отправить содержимое файла в поток
xlsFile.Save( stream );
// сбросить вспомогательный DataSet
ResultDataSet.Tables.Clear();
}
示例3: Export
internal void Export(GroupResultCollection grs)
{
_grs = grs;
string file = Path.GetTempFileName("xls");
XlsFile xls = new XlsFile();
xls.NewFile(GetPersonCount());
int n = 0;
foreach (GroupResult gr in grs)
{
foreach (PersonResult pr in gr.PersonResults)
{
n++;
xls.ActiveSheet = n;
xls.SheetName = GetSheetName(gr, pr);
DataTable tbl = ResultDataTableConverter.ToPersonResultDataTable(pr);
Write(xls, tbl, pr.CalcSumOfWorkTimeSpan());
}
}
xls.Save(file);
Open(file);
}
示例4: TaoTieuDe
public static XlsFile TaoTieuDe(XlsFile xls, DataTable dt, int TuHang, int TuCot, int TuCotCua_DT, int DenCotCua_DT, int SoCotCuaMotTrang)
{
xls.NewFile(1); //Create a new Excel file with 1 sheet.
xls.ActiveSheet = 1; //Set the sheet we are working in.
xls.SheetName = "BaoCao";//Set the names of the sheets
//Global Workbook Options
xls.OptionsAutoCompressPictures = true;
//Tính số trang và số cột cần thêm để đủ một trang
int SoCotDu = (DenCotCua_DT - TuCotCua_DT) % SoCotCuaMotTrang;
int SoCotCanThem = 0;
int TongSoCot = 0;
if (SoCotDu != 0)
{
SoCotCanThem = SoCotCuaMotTrang - SoCotDu;
}
TongSoCot = DenCotCua_DT + SoCotCanThem - TuCotCua_DT;
int SoTrang = TongSoCot / SoCotCuaMotTrang;
int _C = TuCot;
//Styles.
TFlxFormat StyleFmt;
StyleFmt = xls.GetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.Good, 0));
StyleFmt.Font.CharSet = 163;
xls.SetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.Good, 0), StyleFmt);
StyleFmt = xls.GetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.Comma, 0));
StyleFmt.Font.Name = "Calibri";
StyleFmt.Font.Size20 = 220;
StyleFmt.Font.Color = TExcelColor.FromTheme(TThemeColor.Foreground1);
StyleFmt.Font.Family = 2;
StyleFmt.Font.CharSet = 163;
StyleFmt.Format = "_-* #,##0.00\\ _₫_-;\\-* #,##0.00\\ _₫_-;_-* \"-\"??\\ _₫_-;[email protected]_-";
xls.SetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.Comma, 0), StyleFmt);
//Named Ranges
TXlsNamedRange Range;
string RangeName;
RangeName = TXlsNamedRange.GetInternalName(InternalNameRange.Print_Titles);
Range = new TXlsNamedRange(RangeName, 1, 32, "='BaoCao'!$A:$B,'BaoCao'!$1:$7");
//You could also use: Range = new TXlsNamedRange(RangeName, 1, 0, 0, 0, 0, 0, 32);
xls.SetNamedRange(Range);
#region //Printer Settings
THeaderAndFooter HeadersAndFooters = new THeaderAndFooter();
HeadersAndFooters.AlignMargins = true;
HeadersAndFooters.ScaleWithDoc = true;
HeadersAndFooters.DiffFirstPage = false;
HeadersAndFooters.DiffEvenPages = false;
HeadersAndFooters.DefaultHeader = "";
HeadersAndFooters.DefaultFooter = "";
HeadersAndFooters.FirstHeader = "";
HeadersAndFooters.FirstFooter = "";
HeadersAndFooters.EvenHeader = "";
HeadersAndFooters.EvenFooter = "";
xls.SetPageHeaderAndFooter(HeadersAndFooters);
//You can set the margins in 2 ways, the one commented here or the one below:
// TXlsMargins PrintMargins = xls.GetPrintMargins();
// PrintMargins.Left = 0.236220472440945;
// PrintMargins.Top = 0.748031496062992;
// PrintMargins.Right = 0.236220472440945;
// PrintMargins.Bottom = 0.748031496062992;
// PrintMargins.Header = 0.31496062992126;
// PrintMargins.Footer = 0.31496062992126;
// xls.SetPrintMargins(PrintMargins);
xls.SetPrintMargins(new TXlsMargins(0.236220472440945, 0.748031496062992, 0.236220472440945, 0.748031496062992, 0.31496062992126, 0.31496062992126));
xls.PrintXResolution = 600;
xls.PrintYResolution = 0;
xls.PrintOptions = TPrintOptions.LeftToRight;
xls.PrintPaperSize = TPaperSize.A4;
//Printer Driver Settings are a blob of data specific to a printer
//This code is commented by default because normally you do not want to hard code the printer settings of an specific printer.
// byte[] PrinterData = {
// 0x00, 0x00, 0x5C, 0x00, 0x5C, 0x00, 0x31, 0x00, 0x39, 0x00, 0x32, 0x00, 0x2E, 0x00, 0x31, 0x00, 0x36, 0x00, 0x38, 0x00, 0x2E, 0x00, 0x31, 0x00, 0x34, 0x00, 0x30, 0x00, 0x2E, 0x00, 0x37, 0x00, 0x5C, 0x00, 0x48, 0x00, 0x50, 0x00, 0x20, 0x00, 0x4C, 0x00, 0x61, 0x00, 0x73, 0x00, 0x65, 0x00, 0x72, 0x00,
// 0x4A, 0x00, 0x65, 0x00, 0x74, 0x00, 0x20, 0x00, 0x4D, 0x00, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x04, 0x15, 0x06, 0xDC, 0x00, 0x34, 0x03, 0x0F, 0xDF, 0x00, 0x00, 0x02, 0x00, 0x09, 0x00, 0xEA, 0x0A, 0x6F, 0x08, 0x00, 0x00, 0x01, 0x00, 0x07, 0x00, 0x58, 0x02, 0x01, 0x00, 0x01, 0x00, 0x58, 0x02,
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, 0x03, 0xC1, 0x02, 0x00, 0x00, 0x00, 0x00, 0x08, 0x04, 0xF8, 0x02, 0x00, 0x00, 0x00, 0x00, 0x52, 0x04, 0x2E, 0x03, 0x00, 0x00, 0x00, 0x00, 0x9C, 0x04, 0x64, 0x03, 0x00, 0x00, 0x00, 0x00, 0xE6, 0x04, 0x9A, 0x03, 0x00, 0x00, 0x00, 0x00, 0x2F, 0x05, 0xD1, 0x03,
// 0x00, 0x00, 0x00, 0x00, 0x79, 0x05, 0x07, 0x04, 0x00, 0x00, 0x00, 0x00, 0xC3, 0x05, 0x3D, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x53, 0x44, 0x44, 0x4D, 0x00, 0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x48, 0x50, 0x20, 0x4C, 0x61, 0x73, 0x65, 0x72, 0x4A, 0x65, 0x74, 0x20, 0x4D, 0x31, 0x33, 0x31,
// 0x39, 0x66, 0x20, 0x4D, 0x46, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
// 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
// 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1A, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x00,
// 0x00, 0x00, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00,
// 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDE, 0x03, 0x00, 0x00, 0xDE, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x59, 0xC3, 0x13, 0xAE, 0x34, 0x03, 0x00, 0x00, 0x00, 0x00,
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
// };
// TPrinterDriverSettings PrinterDriverSettings = new TPrinterDriveSettings(PrinterData);
//.........这里部分代码省略.........
示例5: TaoTieuDe
/// <summary>
/// tạo tiêu để cho báo cáo
/// </summary>
/// <param name="xls"></param>
/// <param name="dt"></param>
/// <param name="TuHang"></param>
/// <param name="TuCot"></param>
/// <param name="TuCotCua_DT"></param>
/// <param name="DenCotCua_DT"></param>
/// <param name="SoCotTrang1"></param>
/// <param name="SoCotTrangLonHon1"></param>
/// <returns></returns>
public XlsFile TaoTieuDe(XlsFile xls, DataTable dt, int TuHang, int TuCot, int TuCotCua_DT, int DenCotCua_DT, int SoCotTrang1, int SoCotTrangLonHon1)
{
xls.NewFile(1); //Create a new Excel file with 1 sheet.
//Set the names of the sheets
xls.ActiveSheet = 1;
xls.SheetName = "Sheet1";
xls.ActiveSheet = 1; //Set the sheet we are working in.
//Global Workbook Options
xls.OptionsAutoCompressPictures = true;
#region //Styles.
//Styles.
TFlxFormat StyleFmt;
StyleFmt = xls.GetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.Comma, 0));
StyleFmt.Font.Name = "Calibri";
StyleFmt.Font.Size20 = 220;
StyleFmt.Font.Color = TExcelColor.FromTheme(TThemeColor.Foreground1);
StyleFmt.Font.Family = 2;
StyleFmt.Format = "#,##0;-#,##0;;@";
xls.SetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.Comma, 0), StyleFmt);
StyleFmt = xls.GetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.RowLevel, 4));
StyleFmt.Font.Name = "Calibri";
StyleFmt.Font.Size20 = 220;
StyleFmt.Font.Color = TExcelColor.FromTheme(TThemeColor.Foreground1);
StyleFmt.Font.Family = 2;
xls.SetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.RowLevel, 4), StyleFmt);
StyleFmt = xls.GetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.Normal, 0));
StyleFmt.Font.Name = "Calibri";
StyleFmt.Font.Size20 = 220;
StyleFmt.Font.Color = TExcelColor.FromTheme(TThemeColor.Foreground1);
StyleFmt.Font.Family = 2;
xls.SetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.Normal, 0), StyleFmt);
StyleFmt = xls.GetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.Comma0, 0));
StyleFmt.Font.Name = "Calibri";
StyleFmt.Font.Size20 = 220;
StyleFmt.Font.Color = TExcelColor.FromTheme(TThemeColor.Foreground1);
StyleFmt.Font.Family = 2;
StyleFmt.Format = "#,##0;-#,##0;;@";
xls.SetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.Comma0, 0), StyleFmt);
StyleFmt = xls.GetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.Currency0, 0));
StyleFmt.Font.Name = "Calibri";
StyleFmt.Font.Size20 = 220;
StyleFmt.Font.Color = TExcelColor.FromTheme(TThemeColor.Foreground1);
StyleFmt.Font.Family = 2;
StyleFmt.Format = "#,##0;-#,##0;;@";
xls.SetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.Currency0, 0), StyleFmt);
StyleFmt = xls.GetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.Percent, 0));
StyleFmt.Font.Name = "Calibri";
StyleFmt.Font.Size20 = 220;
StyleFmt.Font.Color = TExcelColor.FromTheme(TThemeColor.Foreground1);
StyleFmt.Font.Family = 2;
xls.SetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.Percent, 0), StyleFmt);
StyleFmt = xls.GetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.Currency, 0));
StyleFmt.Font.Name = "Calibri";
StyleFmt.Font.Size20 = 220;
StyleFmt.Font.Color = TExcelColor.FromTheme(TThemeColor.Foreground1);
StyleFmt.Font.Family = 2;
StyleFmt.Format = "#,##0;-#,##0;;@";
xls.SetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.Currency, 0), StyleFmt);
StyleFmt = xls.GetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.RowLevel, 1));
StyleFmt.Font.Name = "Calibri";
StyleFmt.Font.Size20 = 220;
StyleFmt.Font.Color = TExcelColor.FromTheme(TThemeColor.Foreground1);
StyleFmt.Font.Family = 2;
xls.SetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.RowLevel, 1), StyleFmt);
StyleFmt = xls.GetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.RowLevel, 2));
StyleFmt.Font.Name = "Calibri";
StyleFmt.Font.Size20 = 220;
StyleFmt.Font.Color = TExcelColor.FromTheme(TThemeColor.Foreground1);
StyleFmt.Font.Family = 2;
xls.SetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.RowLevel, 2), StyleFmt);
StyleFmt = xls.GetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.ColLevel, 1));
StyleFmt.Font.Name = "Calibri";
StyleFmt.Font.Size20 = 220;
StyleFmt.Font.Color = TExcelColor.FromTheme(TThemeColor.Foreground1);
StyleFmt.Font.Family = 2;
//.........这里部分代码省略.........
示例6: GerarExcel
public void GerarExcel(string Nome_Arquivo_Origem,string Nome_Arquivo_Destino, int CodLayout, Dados d, ProgressBar statusGeracaoArquivo)
{
// Criando Aplicação
XlsFile excelDestino = new XlsFile();
XlsFile excelOrigem = new XlsFile();
excelOrigem.Open(Nome_Arquivo_Origem);
int QtdeLinhas = excelOrigem.RowCount;
//Gerando arquivo de saída
for (int i = 1; i <= excelOrigem.SheetCount; i++)
{
excelOrigem.ActiveSheet = i;
excelDestino.NewFile(1);
//LEITURA DOS DADOS ABAS
int qtdeColunas = excelOrigem.ColCountOnlyData;
if (qtdeColunas > 0)
{
for (int cont = 1; cont <= qtdeColunas; cont++)
{
Object titulo = excelOrigem.GetCellValue(1, cont);
if (titulo != null)
{
string LetraColuna = d.PosicaoVinculada(CodLayout, titulo.ToString());
int numeroColuna;
try
{
numeroColuna = Convert.ToInt16(LetraColuna);
}
catch (Exception)
{
numeroColuna = LetrasParaNumero(LetraColuna);
}
if (LetraColuna != null)
{
excelDestino.InsertAndCopyRange(
new TXlsCellRange(1, cont, QtdeLinhas, cont),
1,
numeroColuna,
1,
TFlxInsertMode.NoneRight,
TRangeCopyMode.All,
excelOrigem,
i
);
}
}
}
int c = 0;
string novoNomeArquivo = Path.GetDirectoryName(Nome_Arquivo_Destino) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(Nome_Arquivo_Destino) + "_" + excelOrigem.SheetName + Path.GetExtension(Nome_Arquivo_Destino);
while (File.Exists(novoNomeArquivo))
{
c++;
novoNomeArquivo = Path.GetDirectoryName(Nome_Arquivo_Destino) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(Nome_Arquivo_Destino) + "_" + excelOrigem.SheetName + i + Path.GetExtension(Nome_Arquivo_Destino);
}
excelDestino.Save(novoNomeArquivo);
}
statusGeracaoArquivo.Value = statusGeracaoArquivo.Value + 1;
}
}
示例7: TaoTieuDe
/// <summary>
/// Tạo tiêu đề
/// </summary>
/// <param name="xls"></param>
/// <returns></returns>
public XlsFile TaoTieuDe(XlsFile xls)
{
xls.NewFile(1); //Create a new Excel file with 1 sheet.
//Set the names of the sheets
xls.ActiveSheet = 1;
xls.SheetName = "Sheet1";
xls.ActiveSheet = 1; //Set the sheet we are working in.
//Global Workbook Options
xls.OptionsAutoCompressPictures = true;
xls.OptionsCheckCompatibility = false;
//Styles.
TFlxFormat StyleFmt;
StyleFmt = xls.GetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.Comma, 0));
StyleFmt.Font.Name = "Calibri";
StyleFmt.Font.Size20 = 220;
StyleFmt.Font.Color = TExcelColor.FromTheme(TThemeColor.Foreground1);
StyleFmt.Font.Family = 2;
StyleFmt.Format = "_(* #,##0.00_);_(* \\(#,##0.00\\);_(* \"-\"??_);_(@_)";
xls.SetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.Comma, 0), StyleFmt);
StyleFmt = xls.GetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.RowLevel, 4));
StyleFmt.Font.Name = "Calibri";
StyleFmt.Font.Size20 = 220;
StyleFmt.Font.Color = TExcelColor.FromTheme(TThemeColor.Foreground1);
StyleFmt.Font.Family = 2;
xls.SetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.RowLevel, 4), StyleFmt);
StyleFmt = xls.GetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.Normal, 0));
StyleFmt.Font.Name = "Calibri";
StyleFmt.Font.Size20 = 220;
StyleFmt.Font.Color = TExcelColor.FromTheme(TThemeColor.Foreground1);
StyleFmt.Font.Family = 2;
xls.SetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.Normal, 0), StyleFmt);
StyleFmt = xls.GetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.Comma0, 0));
StyleFmt.Font.Name = "Calibri";
StyleFmt.Font.Size20 = 220;
StyleFmt.Font.Color = TExcelColor.FromTheme(TThemeColor.Foreground1);
StyleFmt.Font.Family = 2;
StyleFmt.Format = "_(* #,##0_);_(* \\(#,##0\\);_(* \"-\"_);_(@_)";
xls.SetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.Comma0, 0), StyleFmt);
StyleFmt = xls.GetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.Currency0, 0));
StyleFmt.Font.Name = "Calibri";
StyleFmt.Font.Size20 = 220;
StyleFmt.Font.Color = TExcelColor.FromTheme(TThemeColor.Foreground1);
StyleFmt.Font.Family = 2;
StyleFmt.Format = "_(\"$\"* #,##0_);_(\"$\"* \\(#,##0\\);_(\"$\"* \"-\"_);_(@_)";
xls.SetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.Currency0, 0), StyleFmt);
StyleFmt = xls.GetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.Percent, 0));
StyleFmt.Font.Name = "Calibri";
StyleFmt.Font.Size20 = 220;
StyleFmt.Font.Color = TExcelColor.FromTheme(TThemeColor.Foreground1);
StyleFmt.Font.Family = 2;
xls.SetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.Percent, 0), StyleFmt);
StyleFmt = xls.GetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.Currency, 0));
StyleFmt.Font.Name = "Calibri";
StyleFmt.Font.Size20 = 220;
StyleFmt.Font.Color = TExcelColor.FromTheme(TThemeColor.Foreground1);
StyleFmt.Font.Family = 2;
StyleFmt.Format = "_(\"$\"* #,##0.00_);_(\"$\"* \\(#,##0.00\\);_(\"$\"* \"-\"??_);_(@_)";
xls.SetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.Currency, 0), StyleFmt);
StyleFmt = xls.GetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.RowLevel, 1));
StyleFmt.Font.Name = "Calibri";
StyleFmt.Font.Size20 = 220;
StyleFmt.Font.Color = TExcelColor.FromTheme(TThemeColor.Foreground1);
StyleFmt.Font.Family = 2;
xls.SetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.RowLevel, 1), StyleFmt);
StyleFmt = xls.GetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.RowLevel, 2));
StyleFmt.Font.Name = "Calibri";
StyleFmt.Font.Size20 = 220;
StyleFmt.Font.Color = TExcelColor.FromTheme(TThemeColor.Foreground1);
StyleFmt.Font.Family = 2;
xls.SetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.RowLevel, 2), StyleFmt);
StyleFmt = xls.GetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.ColLevel, 1));
StyleFmt.Font.Name = "Calibri";
StyleFmt.Font.Size20 = 220;
StyleFmt.Font.Color = TExcelColor.FromTheme(TThemeColor.Foreground1);
StyleFmt.Font.Family = 2;
xls.SetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.ColLevel, 1), StyleFmt);
StyleFmt = xls.GetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.ColLevel, 2));
StyleFmt.Font.Name = "Calibri";
StyleFmt.Font.Size20 = 220;
StyleFmt.Font.Color = TExcelColor.FromTheme(TThemeColor.Foreground1);
StyleFmt.Font.Family = 2;
//.........这里部分代码省略.........
示例8: Export
internal override void Export()
{
// begin first station head row
//
int row = ReportConfig.BeginRow;
XlsFile xls = new XlsFile();
//xls.Open(_xlsPath);
xls.NewFile(1);
string title = string.Format(
"����վ���ȳɱ����� {0} ~ {1}",
B, E);
SetCellValue(xls, ReportConfig.Title, title);
SetCellValue(xls, ReportConfig.AvgOTText, "����ƽ���¶�", false);
SetCellValue(xls, ReportConfig.AVGOTValue, ReportHelper.GetAvgOT(B, E));
//double[] values = ReportHelper.GetAvgValues(B, E);
// add first station head text
//
for (int i = 0; i < ReportConfig.FirstStationHeads.Length; i++)
{
string value = ReportConfig.FirstStationHeads[i];
SetCellValue(xls, row, i + 1, value, true);
}
row++;
DataTable firstStationDataTbl = ReportHelper.GetFirstStationAvgDataTable(B, E);
foreach (DataRow dataRow in firstStationDataTbl.Rows)
{
//foreach (string columnName in ReportConfig.FirstStationColumnNames)
for (int i = 0; i < ReportConfig.FirstStationColumnNames.Length; i++)
{
string columnName = ReportConfig.FirstStationColumnNames[i];
SetCellValue(xls, row, i + 1, dataRow[columnName], true);
}
row++;
}
// empty line
//
row++;
for (int i = 0; i < ReportConfig.StationHeads.Length; i++)
{
SetCellValue(xls, row, i + 1, ReportConfig.StationHeads[i], true);
}
row++;
//SetCellValue(xls, ReportConfig.AVGGT1, values[0]);
//SetCellValue(xls, ReportConfig.AVGBT1, values[1]);
//SetCellValue(xls, ReportConfig.AVGI1, values[2]);
//SetCellValue(xls, ReportConfig.DT, DateTime.Now.ToString("yyyy-MM-dd"));
// �պ����� = ������ * ( һ�ι��� - һ�λ��� ) * 4.1816 / 1000
//
DataTable tbl = ReportHelper.GetStationData(B, E);
DataColumn heatCol = new DataColumn(
"heat",
typeof(double),
"(maxs1 - mins1) * (gt1 - bt1) * 4.1816 / 1000");
tbl.Columns.Add(heatCol);
DataColumn recuriteCol = new DataColumn("recurite",
typeof(double),
"maxsr-minsr");
tbl.Columns.Add(recuriteCol);
for (int i = 0; i < tbl.Rows.Count; i++)
{
//int r = ReportConfig.BeginRow + i;
FillXlsRowWithEmpty(xls, row, ReportConfig.TotalColumns);
DataRow dataRow = tbl.Rows[i];
double heatValue = Math.Round(Convert.ToDouble(dataRow["heat"]), ReportHelper.DotNumber);
if (heatValue < 0)
{
heatValue = 0;
}
SetCellValue(xls, row, ReportConfig.HeatCol,
heatValue,
true);
SetCellValue(xls, row, ReportConfig.RecuritFluxCol,
Math.Round(Convert.ToDouble(dataRow["recurite"]), ReportHelper.DotNumber),
true);
SetCellValue(xls, row, ReportConfig.StationNameCol,
dataRow["StationName"].ToString(), true);
row++;
}
double sumHeat = 0d;
double sumRecurite = 0d;
//.........这里部分代码省略.........
示例9: TaoTieuDe_A3
public static XlsFile TaoTieuDe_A3(XlsFile xls, DataTable dt, int TuHang, int TuCot, int TuCotCua_DT, int DenCotCua_DT, int SoCotTrang1, int SoCotTrangLonHon1, Boolean NghiepVu = false)
{
xls.NewFile(1); //Create a new Excel file with 1 sheet.
//Set the names of the sheets
xls.ActiveSheet = 1;
xls.SheetName = "Sheet1";
xls.ActiveSheet = 1; //Set the sheet we are working in.
//Global Workbook Options
xls.OptionsAutoCompressPictures = true;
#region //Styles.
TFlxFormat StyleFmt;
StyleFmt = xls.GetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.Comma, 0));
StyleFmt.Font.Name = "Calibri";
StyleFmt.Font.Size20 = 220;
StyleFmt.Font.Color = TExcelColor.FromTheme(TThemeColor.Foreground1);
StyleFmt.Font.Family = 2;
StyleFmt.Format = "_(* #,##0.00_);_(* \\(#,##0.00\\);_(* \"-\"??_);_(@_)";
xls.SetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.Comma, 0), StyleFmt);
StyleFmt = xls.GetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.RowLevel, 4));
StyleFmt.Font.Name = "Calibri";
StyleFmt.Font.Size20 = 220;
StyleFmt.Font.Color = TExcelColor.FromTheme(TThemeColor.Foreground1);
StyleFmt.Font.Family = 2;
xls.SetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.RowLevel, 4), StyleFmt);
StyleFmt = xls.GetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.Normal, 0));
StyleFmt.Font.Name = "Calibri";
StyleFmt.Font.Size20 = 220;
StyleFmt.Font.Color = TExcelColor.FromTheme(TThemeColor.Foreground1);
StyleFmt.Font.Family = 2;
xls.SetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.Normal, 0), StyleFmt);
StyleFmt = xls.GetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.Comma0, 0));
StyleFmt.Font.Name = "Calibri";
StyleFmt.Font.Size20 = 220;
StyleFmt.Font.Color = TExcelColor.FromTheme(TThemeColor.Foreground1);
StyleFmt.Font.Family = 2;
StyleFmt.Format = "_(* #,##0_);_(* \\(#,##0\\);_(* \"-\"_);_(@_)";
xls.SetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.Comma0, 0), StyleFmt);
StyleFmt = xls.GetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.Currency0, 0));
StyleFmt.Font.Name = "Calibri";
StyleFmt.Font.Size20 = 220;
StyleFmt.Font.Color = TExcelColor.FromTheme(TThemeColor.Foreground1);
StyleFmt.Font.Family = 2;
StyleFmt.Format = "_(\"$\"* #,##0_);_(\"$\"* \\(#,##0\\);_(\"$\"* \"-\"_);_(@_)";
xls.SetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.Currency0, 0), StyleFmt);
StyleFmt = xls.GetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.Percent, 0));
StyleFmt.Font.Name = "Calibri";
StyleFmt.Font.Size20 = 220;
StyleFmt.Font.Color = TExcelColor.FromTheme(TThemeColor.Foreground1);
StyleFmt.Font.Family = 2;
xls.SetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.Percent, 0), StyleFmt);
StyleFmt = xls.GetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.Currency, 0));
StyleFmt.Font.Name = "Calibri";
StyleFmt.Font.Size20 = 220;
StyleFmt.Font.Color = TExcelColor.FromTheme(TThemeColor.Foreground1);
StyleFmt.Font.Family = 2;
StyleFmt.Format = "_(\"$\"* #,##0.00_);_(\"$\"* \\(#,##0.00\\);_(\"$\"* \"-\"??_);_(@_)";
xls.SetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.Currency, 0), StyleFmt);
StyleFmt = xls.GetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.RowLevel, 1));
StyleFmt.Font.Name = "Calibri";
StyleFmt.Font.Size20 = 220;
StyleFmt.Font.Color = TExcelColor.FromTheme(TThemeColor.Foreground1);
StyleFmt.Font.Family = 2;
xls.SetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.RowLevel, 1), StyleFmt);
StyleFmt = xls.GetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.RowLevel, 2));
StyleFmt.Font.Name = "Calibri";
StyleFmt.Font.Size20 = 220;
StyleFmt.Font.Color = TExcelColor.FromTheme(TThemeColor.Foreground1);
StyleFmt.Font.Family = 2;
xls.SetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.RowLevel, 2), StyleFmt);
StyleFmt = xls.GetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.ColLevel, 1));
StyleFmt.Font.Name = "Calibri";
StyleFmt.Font.Size20 = 220;
StyleFmt.Font.Color = TExcelColor.FromTheme(TThemeColor.Foreground1);
StyleFmt.Font.Family = 2;
xls.SetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.ColLevel, 1), StyleFmt);
StyleFmt = xls.GetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.ColLevel, 2));
StyleFmt.Font.Name = "Calibri";
StyleFmt.Font.Size20 = 220;
StyleFmt.Font.Color = TExcelColor.FromTheme(TThemeColor.Foreground1);
StyleFmt.Font.Family = 2;
xls.SetStyle(xls.GetBuiltInStyleName(TBuiltInStyle.ColLevel, 2), StyleFmt);
#endregion
#region //Named Ranges
TXlsNamedRange Range;
string RangeName;
//.........这里部分代码省略.........