本文整理汇总了C#中IDataSource.Open方法的典型用法代码示例。如果您正苦于以下问题:C# IDataSource.Open方法的具体用法?C# IDataSource.Open怎么用?C# IDataSource.Open使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDataSource
的用法示例。
在下文中一共展示了IDataSource.Open方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Do
public bool Do(string configurationFilePath)
{
try
{
Console.WriteLine("--- Load configuration file ---");
configurationFilePath = Environment.ExpandEnvironmentVariables(configurationFilePath);
XDocument xDocument = XDocument.Parse(File.ReadAllText(configurationFilePath));
//// Options
var xmlOptions = xDocument.Root.Element("Options");
// DataSource
Console.WriteLine("Load spreadsheet");
dataSource = new Spreadsheet();
dataSource.Open(Environment.ExpandEnvironmentVariables(xmlOptions.Element("DataSource").Element("Parameter").Value));
((Spreadsheet)dataSource).SetSheet(xmlOptions.Element("Spreadsheet").Element("Table").Value);
// PDF
Console.WriteLine("Load PDF");
pdf = new PDF();
pdf.Open(Environment.ExpandEnvironmentVariables(xmlOptions.Element("PDF").Element("Filepath").Value));
//// PDFFieldValues
Console.WriteLine("Load field configuration");
Dictionary<string, PDFField> pdfFields = new Dictionary<string, PDFField>();
foreach (var node in xDocument.Root.Element("PDFFieldValues").Descendants("PDFFieldValue"))
{
var pdfField = new PDFField();
pdfField.Name = node.Element("Name").Value;
pdfField.DataSourceValue = node.Element("NewValue").Value;
pdfField.UseValueFromDataSource = Convert.ToBoolean(node.Element("UseValueFromDataSource").Value);
pdfField.MakeReadOnly = Convert.ToBoolean(node.Element("MakeReadOnly").Value);
pdfFields.Add(pdfField.Name, pdfField);
}
//// Filename
Console.WriteLine("Load filename options");
var xmlFilename = xmlOptions.Element("Filename");
prefix = xmlFilename.Element("Prefix").Value;
useValueFromDataSource = Convert.ToBoolean(xmlFilename.Element("ValueFromDataSource").Value);
DataSourceColumnsFilenameIndex = ((Spreadsheet)dataSource).Columns.IndexOf(xmlFilename.Element("DataSource").Value);
suffix = xmlFilename.Element("Suffix").Value;
useRowNumber = Convert.ToBoolean(xmlFilename.Element("RowNumber").Value);
//// Other
Console.WriteLine("Load general options");
bool finalize = Convert.ToBoolean(xmlOptions.Element("Finalize").Value);
string outputDir = Environment.ExpandEnvironmentVariables(xmlOptions.Element("OutputDir").Value);
Console.WriteLine("--- Start processing ---");
PDFFiller.CreateFiles(pdf, finalize, dataSource, pdfFields, outputDir + @"\", ConcatFilename, WriteLinePercent);
Console.WriteLine("!!! Finished !!!");
}
catch (Exception e)
{
Console.WriteLine(e.Message);
return false;
}
return true;
}