本文整理汇总了C#中Workbook.Combine方法的典型用法代码示例。如果您正苦于以下问题:C# Workbook.Combine方法的具体用法?C# Workbook.Combine怎么用?C# Workbook.Combine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Workbook
的用法示例。
在下文中一共展示了Workbook.Combine方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
public static void Main(string[] args)
{
// The path to the documents directory.
string dataDir = Path.GetFullPath("../../../Data/");
//Define the first source
//Open the first excel file.
Workbook SourceBook1 = new Workbook(dataDir+ "SampleChart.xlsx");
//Define the second source book.
//Open the second excel file.
Workbook SourceBook2 = new Workbook(dataDir+ "SampleImage.xlsx");
//Combining the two workbooks
SourceBook1.Combine(SourceBook2);
//Save the target book file.
SourceBook1.Save(dataDir+ "Combined.xlsx");
}
示例2: Main
public static void Main(string[] args)
{
// The path to the documents directory.
string dataDir = Aspose.Cells.Examples.Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
//Define the first source
//Open the first excel file.
Workbook SourceBook1 = new Workbook(dataDir+ "SampleChart.xlsx");
//Define the second source book.
//Open the second excel file.
Workbook SourceBook2 = new Workbook(dataDir+ "SampleImage.xlsx");
//Combining the two workbooks
SourceBook1.Combine(SourceBook2);
//Save the target book file.
SourceBook1.Save(dataDir+ "Combined.xlsx");
}
示例3: Run
public static void Run()
{
// ExStart:1
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Define the first source
// Open the first excel file.
Workbook SourceBook1 = new Workbook(dataDir+ "SampleChart.xlsx");
// Define the second source book.
// Open the second excel file.
Workbook SourceBook2 = new Workbook(dataDir+ "SampleImage.xlsx");
// Combining the two workbooks
SourceBook1.Combine(SourceBook2);
dataDir = dataDir + "Combined.out.xlsx";
// Save the target book file.
SourceBook1.Save(dataDir);
// ExEnd:1
Console.WriteLine("\nProcess completed successfully.\nFile saved at " + dataDir);
}
开发者ID:aspose-cells,项目名称:Aspose.Cells-for-.NET,代码行数:23,代码来源:CombineMultipleWorkbooksSingleWorkbook.cs
示例4: Execute
public void Execute()
{
try
{
DialogResult dialogResult = this._User_Form.ShowDialog();
if (dialogResult != DialogResult.OK)
return;
this._Statistics = this._User_Form.SelectedStatistics;
this._FileType = this._User_Form.FileType;
Task<Dictionary<string, Workbook>> task = Task<Dictionary<string, Workbook>>.Factory.StartNew(() =>
{
List<UDT.QHRelation> QHRelations = Access.Select<UDT.QHRelation>();
List<UDT.Hierarchy> Hierarchies = Access.Select<UDT.Hierarchy>();
Dictionary<string, Workbook> dicSurveyIDs = new Dictionary<string, Workbook>();
Dictionary<string, List<Workbook>> dicWorkbooks = new Dictionary<string, List<Workbook>>();
//Parallel.ForEach<UDT.TeacherStatistics>(this._Statistics, x =>
//{
this._Statistics.ForEach((x) =>
{
try
{
XDocument xDocument = XDocument.Parse(x.StatisticsList, LoadOptions.None);
XElement xStatistics = xDocument.Element("Statistics");
string SurveyID = xStatistics.Attribute("SurveyID").Value;
lock (dicSurveyIDs)
{
if (!dicSurveyIDs.ContainsKey(SurveyID))
dicSurveyIDs.Add(SurveyID, this.GetSurveyTemplate(SurveyID));
}
ExcelDocumentMaker excelDocumentMaker = null;// new ExcelDocumentMaker(QHRelations, Hierarchies, x, dicSurveyIDs[SurveyID]);
Workbook wb = excelDocumentMaker.Produce();
if (wb != null)
{
string key = string.Empty;
if (this._FileType == 1)
key = excelDocumentMaker.SubjectName + "-課程教學評鑑統計表";
if (this._FileType == 2)
key = excelDocumentMaker.CourseName + "-開課教學評鑑統計表";
if (this._FileType == 3)
key = excelDocumentMaker.TeacherName + "-授課教師教學評鑑統計表";
lock (dicWorkbooks)
{
if (!dicWorkbooks.ContainsKey(key))
dicWorkbooks.Add(key, new List<Workbook>());
dicWorkbooks[key].Add(wb);
}
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
});
Dictionary<string, Workbook> dicFiles = new Dictionary<string, Workbook>();
try
{
foreach (string key in dicWorkbooks.Keys)
{
Workbook new_workbook = new Workbook();
foreach (Workbook wb in dicWorkbooks[key])
{
new_workbook.Combine(wb);
wb.Worksheets.Cast<Worksheet>().ToList().ForEach(x => wb.Worksheets.RemoveAt(x.Index));
}
new_workbook.Worksheets.Cast<Worksheet>().ToList().ForEach((x) =>
{
if (x.Cells.MaxDataColumn == 0 && x.Cells.MaxDataRow == 0)
new_workbook.Worksheets.RemoveAt(x.Index);
});
dicFiles.Add(key, new_workbook);
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
if (dicFiles.Count == 0)
throw new Exception("無檔案產生。");
return dicFiles;
});
task.ContinueWith((x) =>
{
if (x.Exception != null)
{
MessageBox.Show(x.Exception.InnerException.Message);
return;
}
string filePath = string.Empty;
System.Windows.Forms.FolderBrowserDialog folder = new FolderBrowserDialog();
do
{
DialogResult dr = folder.ShowDialog();
if (dr == DialogResult.OK)
//.........这里部分代码省略.........
开发者ID:jungfengpaulwang,项目名称:EMBATeachingEvaluation,代码行数:101,代码来源:ExportEvaluation_ComplexQueries_Handler.cs
示例5: btnSubjectSemesterScoreHistory_Click
private void btnSubjectSemesterScoreHistory_Click(object sender, EventArgs e)
{
this.circularProgress.Visible = true;
this.circularProgress.IsRunning = true;
this.btnPrint.Enabled = false;
int SchoolYear = int.Parse(this.nudSchoolYear.Value + "");
int Semester = int.Parse((this.cboSemester.SelectedItem as EMBACore.DataItems.SemesterItem).Value);
Task<Workbook> task = Task<Workbook>.Factory.StartNew(() =>
{
Workbook new_workbook = new Workbook();
foreach (string key in this.dicStudents.Keys)
{
Workbook wb = this.GenerateWorkbook(this.dicStudents[key], SchoolYear, Semester);
new_workbook.Combine(wb);
new_workbook.Worksheets.Cast<Worksheet>().ToList().ForEach((x) =>
{
if (x.Cells.MaxDataColumn == 0 && x.Cells.MaxDataRow == 0)
new_workbook.Worksheets.RemoveAt(x.Index);
});
}
return new_workbook;
});
task.ContinueWith((x) =>
{
this.circularProgress.Visible = false;
this.circularProgress.IsRunning = false;
this.btnPrint.Enabled = true;
if (x.Exception != null)
{
MessageBox.Show(x.Exception.InnerException.Message);
return;
}
System.Windows.Forms.SaveFileDialog sd = new System.Windows.Forms.SaveFileDialog();
sd.Title = "另存新檔";
sd.FileName = "歷年成績表" + DateTime.Now.ToString(" yyyy-MM-dd_HH_mm_ss") + ".xls";
sd.Filter = "Excel檔案 (*.xls)|*.xls|所有檔案 (*.*)|*.*";
sd.AddExtension = true;
if (sd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
try
{
x.Result.Save(sd.FileName, FileFormatType.Excel2003);
System.Diagnostics.Process.Start(sd.FileName);
}
catch
{
FISCA.Presentation.Controls.MsgBox.Show("指定路徑無法存取。", "建立檔案失敗", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
return;
}
}
}, System.Threading.CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext());
}
示例6: btnExport_Click
//.........这里部分代码省略.........
dicStatistics[file_name].Add(x);
});
if (Empty_Survey.Count>0)
{
throw new Exception(string.Format("請先設定下列評鑑之教學意見表樣版:\n\n{0}", string.Join("\n", Empty_Survey.Distinct())));
}
// 統計群組、背景顏色
List<UDT.StatisticsGroup> StatisticsGroups = Access.Select<UDT.StatisticsGroup>();
Dictionary<string, Dictionary<string, Color>> dicQuestionBackgroundColor = new Dictionary<string, Dictionary<string, Color>>();
Dictionary<string, Dictionary<string, Color>> dicEvaluationBackgroundColor = new Dictionary<string, Dictionary<string, Color>>();
StatisticsGroups.ForEach((x) =>
{
XDocument xxDocument = XDocument.Parse(x.DisplayOrderList, LoadOptions.None);
List<XElement> xElements = xxDocument.Descendants("Question").ToList();
if (!string.IsNullOrEmpty(x.QuestionBgColor) && xElements.Count() > 0)
{
foreach (string display_order in xElements.Select(y => y.Attribute("DisplayOrder").Value))
{
if (!dicQuestionBackgroundColor.ContainsKey(x.SurveyID.ToString()))
dicQuestionBackgroundColor.Add(x.SurveyID.ToString(), new Dictionary<string, Color>());
if (!dicQuestionBackgroundColor[x.SurveyID.ToString()].ContainsKey(display_order))
dicQuestionBackgroundColor[x.SurveyID.ToString()].Add(display_order, Color.FromName(x.QuestionBgColor));
else
{
if (Color.FromName(x.QuestionBgColor) != Color.White)
dicQuestionBackgroundColor[x.SurveyID.ToString()][display_order] = Color.FromName(x.QuestionBgColor);
}
}
}
if (!dicEvaluationBackgroundColor.ContainsKey(x.SurveyID.ToString()))
dicEvaluationBackgroundColor.Add(x.SurveyID.ToString(), new Dictionary<string, Color>());
if (!dicEvaluationBackgroundColor[x.SurveyID.ToString()].ContainsKey(x.Name))
dicEvaluationBackgroundColor[x.SurveyID.ToString()].Add(x.Name, Color.FromName(x.EvaluationBgColor));
});
Workbook wb = new Workbook();
foreach (string key in dicStatistics.Keys)
{
Workbook new_workbook = new Workbook();
//new_workbook.Worksheets.Cast<Worksheet>().ToList().ForEach(x => new_workbook.Worksheets.RemoveAt(x.Index));
foreach (UDT.TeacherStatistics Statistic in dicStatistics[key])
{
wb = MakeExcelDocument(Statistic, dicQuestionHierarchies, dicQuestionBackgroundColor, dicEvaluationBackgroundColor);
new_workbook.Combine(wb);
wb.Worksheets.Cast<Worksheet>().ToList().ForEach(x => wb.Worksheets.RemoveAt(x.Index));
}
new_workbook.Worksheets.Cast<Worksheet>().ToList().ForEach((x) =>
{
if (x.Cells.MaxDataColumn == 0 && x.Cells.MaxDataRow == 0)
new_workbook.Worksheets.RemoveAt(x.Index);
});
dicFiles.Add(key, new_workbook);
}
return dicFiles;
});
task.ContinueWith((x) =>
{
this.circularProgress.IsRunning = false;
this.circularProgress.Visible = false;
this.btnQuery.Enabled = true;
this.btnExport.Enabled = true;
this.btnExit.Enabled = true;
if (x.Exception != null)
{
MessageBox.Show(x.Exception.InnerException.Message);
return;
}
string filePath = string.Empty;
System.Windows.Forms.FolderBrowserDialog folder = new FolderBrowserDialog();
do
{
DialogResult dr = folder.ShowDialog();
if (dr == DialogResult.OK)
filePath = folder.SelectedPath;
if (dr == DialogResult.Cancel)
return;
} while (!System.IO.Directory.Exists(filePath));
foreach (string fileName in x.Result.Keys)
{
try
{
// 檔案名稱不能有下列字元<>:"/\|?*
string new_fileName = fileName.Replace(":", "꞉").Replace(":", "꞉").Replace("/", "⁄").Replace("/", "⁄").Replace(@"\", "∖").Replace("\", "∖").Replace("?", "_").Replace("?", "_").Replace("*", "✻").Replace("*", "✻").Replace("<", "〈").Replace("<", "〈").Replace(">", "〉").Replace(">", "〉").Replace("\"", "''").Replace("”", "''").Replace("|", "ㅣ").Replace("|", "ㅣ");
x.Result[fileName].Save(Path.Combine(filePath, new_fileName + ".xls"), FileFormatType.Excel2003);
System.Diagnostics.Process.Start(filePath);
}
catch
{
MessageBox.Show("指定路徑無法存取。", "建立檔案失敗", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}, System.Threading.CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext());
}
开发者ID:jungfengpaulwang,项目名称:EMBATeachingEvaluation,代码行数:101,代码来源:ExportEvaluation_ComplexQuerie_2014.cs