本文整理汇总了C#中LoadOptions类的典型用法代码示例。如果您正苦于以下问题:C# LoadOptions类的具体用法?C# LoadOptions怎么用?C# LoadOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LoadOptions类属于命名空间,在下文中一共展示了LoadOptions类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Run
public static void Run()
{
// ExStart:1
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Load only specific sheets with data and formulas
// Other objects, items etc. would be discarded
// Instantiate LoadOptions specified by the LoadFormat
LoadOptions loadOptions7 = new LoadOptions(LoadFormat.Xlsx);
// Set the LoadDataOption
LoadDataOption dataOption = new LoadDataOption();
// Specify the sheet(s) in the template file to be loaded
dataOption.SheetNames = new string[] { "Sheet2" };
dataOption.ImportFormula = true;
// Only data and formatting should be loaded.
loadOptions7.LoadDataAndFormatting = true;
// Specify the LoadDataOption
loadOptions7.LoadDataOptions = dataOption;
// Create a Workbook object and opening the file from its path
Workbook wb = new Workbook(dataDir + "Book1.xlsx", loadOptions7);
Console.WriteLine("File data imported successfully!");
// ExEnd:1
}
开发者ID:aspose-cells,项目名称:Aspose.Cells-for-.NET,代码行数:27,代码来源:OpeningFilewithDataOnly.cs
示例2: Main
static void Main(string[] args)
{
LoadOptions loadOptions = new LoadOptions(LoadFormat.CSV);
Workbook newWorkbook = new Workbook(TextFile, loadOptions);
newWorkbook.Save(fileName);
}
开发者ID:assadvirgo,项目名称:Aspose_Cells_NET,代码行数:7,代码来源:Program.cs
示例3: LoadItem
protected override Item LoadItem(Item item, LoadOptions options)
{
Assert.ArgumentNotNull(item, "item");
var itemData = new ItemData(item);
var configuration = _helper.GetConfigurationForItem(itemData);
if (configuration == null) return base.LoadItem(item, options);
var sourceStore = configuration.Resolve<ISourceDataStore>();
var targetStore = configuration.Resolve<ITargetDataStore>();
var targetItem = targetStore.GetByPathAndId(itemData.Path, itemData.Id, itemData.DatabaseName);
if (targetItem == null)
{
Log.Warn("Unicorn: Unable to load item because it was not serialized.", this);
return base.LoadItem(item, options);
}
sourceStore.Save(targetItem);
return Database.GetItem(item.Uri);
}
开发者ID:ramnkl,项目名称:Unicorn,代码行数:25,代码来源:UnicornLoadItemCommand.cs
示例4: GetForKey
public static ApprovalStatus GetForKey(String code, LoadOptions options)
{
ApprovalStatus status = null;
if (options == LoadOptions.DiskOnly)
{
status = ShortSaleSchemaSession.GetContext().ApprovalStatus.Single(o => o.Code == code);
cache[code] = status;
}
else
{
try
{
status = cache[code];
}
catch (KeyNotFoundException ex)
{
if (options == LoadOptions.CacheFirst)
{
status = ShortSaleSchemaSession.GetContext().ApprovalStatus.Single(o => o.Code == code);
cache[code] = status;
}
else
{
throw ex;
}
}
}
return status;
}
开发者ID:heimanhon,项目名称:researchwork,代码行数:30,代码来源:ApprovalStatus.cs
示例5: ToXDocument
/// <summary>
/// Converts XmlDocument to XDocument using load options.
/// </summary>
/// <param name="document">
/// The input document to be converted.
/// </param>
/// <param name="options">
/// The options for the conversion.
/// </param>
/// <returns>
/// Resulting XDocument.
/// </returns>
public static XDocument ToXDocument(this XmlDocument document, LoadOptions options)
{
using (XmlNodeReader reader = new XmlNodeReader(document))
{
return XDocument.Load(reader, options);
}
}
开发者ID:chien-andalou,项目名称:QuickRoutes,代码行数:19,代码来源:XmlDocumentExtensions.cs
示例6: ConvertToRtfPwd
public bool ConvertToRtfPwd(string source, string target, string password)
{
LoadOptions lo = new LoadOptions(password);
Document doc = new Document(source, lo);
doc.Save(target, SaveFormat.Rtf);
return true;
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:7,代码来源:AsposeConverter.cs
示例7: 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);
string sampleFile = "Sample.out.xlsx";
string samplePath = dataDir + sampleFile;
// Create a sample workbook
// and put some data in first cell of all 3 sheets
Workbook createWorkbook = new Workbook();
createWorkbook.Worksheets["Sheet1"].Cells["A1"].Value = "Aspose";
createWorkbook.Worksheets.Add("Sheet2").Cells["A1"].Value = "Aspose";
createWorkbook.Worksheets.Add("Sheet3").Cells["A1"].Value = "Aspose";
createWorkbook.Worksheets["Sheet3"].IsVisible = false;
createWorkbook.Save(samplePath);
// Load the sample workbook
LoadDataOption loadDataOption = new LoadDataOption();
loadDataOption.OnlyVisibleWorksheet = true;
LoadOptions loadOptions = new LoadOptions();
loadOptions.LoadDataAndFormatting = true;
loadOptions.LoadDataOptions = loadDataOption;
Workbook loadWorkbook = new Workbook(samplePath, loadOptions);
Console.WriteLine("Sheet1: A1: {0}", loadWorkbook.Worksheets["Sheet1"].Cells["A1"].Value);
Console.WriteLine("Sheet1: A2: {0}", loadWorkbook.Worksheets["Sheet2"].Cells["A1"].Value);
Console.WriteLine("Sheet1: A3: {0}", loadWorkbook.Worksheets["Sheet3"].Cells["A1"].Value);
}
开发者ID:nesterenes,项目名称:Aspose_Cells_NET,代码行数:28,代码来源:LoadVisibleSheetsOnly.cs
示例8: Run
public static void Run()
{
// ExStart:1
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Define a new Workbook.
Workbook workbook;
// Set the load data option with selected sheet(s).
LoadDataOption dataOption = new LoadDataOption();
dataOption.SheetNames = new string[] { "Sheet2" };
// Load the workbook with the spcified worksheet only.
LoadOptions loadOptions = new LoadOptions(LoadFormat.Xlsx);
loadOptions.LoadDataOptions = dataOption;
loadOptions.LoadDataAndFormatting = true;
// Creat the workbook.
workbook = new Workbook(dataDir+ "TestData.xlsx", loadOptions);
// Perform your desired task.
// Save the workbook.
workbook.Save(dataDir+ "outputFile.out.xlsx");
// ExEnd:1
}
开发者ID:aspose-cells,项目名称:Aspose.Cells-for-.NET,代码行数:27,代码来源:LoadSpecificSheets.cs
示例9: Run
public static void Run()
{
// ExStart:1
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Create a sample workbook and add some data inside the first worksheet
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
worksheet.Cells["P30"].PutValue("This is sample data.");
// Save the workbook in memory stream
MemoryStream ms = new MemoryStream();
workbook.Save(ms, SaveFormat.Xlsx);
ms.Position = 0;
// Now load the workbook from memory stream with A5 paper size
LoadOptions opts = new LoadOptions(LoadFormat.Xlsx);
opts.SetPaperSize(PaperSizeType.PaperA5);
workbook = new Workbook(ms, opts);
// Save the workbook in pdf format
workbook.Save(dataDir + "LoadWorkbookWithPrinterSize-a5_out.pdf");
// Now load the workbook again from memory stream with A3 paper size
ms.Position = 0;
opts = new LoadOptions(LoadFormat.Xlsx);
opts.SetPaperSize(PaperSizeType.PaperA3);
workbook = new Workbook(ms, opts);
// Save the workbook in pdf format
workbook.Save(dataDir + "LoadWorkbookWithPrinterSize-a3_out.pdf");
// ExEnd:1
}
开发者ID:aspose-cells,项目名称:Aspose.Cells-for-.NET,代码行数:34,代码来源:LoadWorkbookWithPrinterSize.cs
示例10: Run
public static void Run()
{
// ExStart:LoadWorkbookWithSpecificCultureInfoDateFormat
using (var inputStream = new MemoryStream())
{
using (var writer = new StreamWriter(inputStream))
{
writer.WriteLine("<html><head><title>Test Culture</title></head><body><table><tr><td>10-01-2016</td></tr></table></body></html>");
writer.Flush();
var culture = new CultureInfo("en-GB");
culture.NumberFormat.NumberDecimalSeparator = ",";
culture.DateTimeFormat.DateSeparator = "-";
culture.DateTimeFormat.ShortDatePattern = "dd-MM-yyyy";
LoadOptions options = new LoadOptions(LoadFormat.Html);
options.CultureInfo = culture;
using (var workbook = new Workbook(inputStream, options))
{
var cell = workbook.Worksheets[0].Cells["A1"];
Assert.AreEqual(CellValueType.IsDateTime, cell.Type);
Assert.AreEqual(new DateTime(2016, 1, 10), cell.DateTimeValue);
}
}
}
// ExEnd:LoadWorkbookWithSpecificCultureInfoDateFormat
}
开发者ID:aspose-cells,项目名称:Aspose.Cells-for-.NET,代码行数:27,代码来源:LoadWorkbookWithSpecificCultureInfoDateFormat.cs
示例11: Run
public static void Run()
{
// ExStart:ReadVisioDiagram
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadSaveConvert();
// Call the diagram constructor to load a VSD stream
FileStream st = new FileStream(dataDir + "Drawing1.vsdx", FileMode.Open);
Diagram vsdDiagram = new Diagram(st);
st.Close();
// Call the diagram constructor to load a VDX diagram
Diagram vdxDiagram = new Diagram(dataDir + "Drawing1.vdx");
/*
* Call diagram constructor to load a VSS stencil
* providing load file format
*/
Diagram vssDiagram = new Diagram(dataDir + "Basic.vss", LoadFileFormat.VSS);
/*
* Call diagram constructor to load diagram from a VSX file
* providing load options
*/
LoadOptions loadOptions = new LoadOptions(LoadFileFormat.VSX);
Diagram vsxDiagram = new Diagram(dataDir + "Drawing1.vsx", loadOptions);
// ExEnd:ReadVisioDiagram
}
开发者ID:aspose-diagram,项目名称:Aspose.Diagram-for-.NET,代码行数:28,代码来源:ReadVisioDiagram.cs
示例12: ToXDocument
public static XDocument ToXDocument(this XmlDocument xmlDocument, LoadOptions options = LoadOptions.None)
{
using (var nodeReader = new XmlNodeReader(xmlDocument))
{
nodeReader.MoveToContent();
return XDocument.Load(nodeReader, options);
}
}
开发者ID:erashid,项目名称:Extensions,代码行数:8,代码来源:XmlDocumentExtension.cs
示例13: ConvertToDocPwd
public bool ConvertToDocPwd(string source, string target, string password)
{
// TODO: Add logging
LoadOptions lo = new LoadOptions(password);
Document document = new Document(source, lo);
document.Save(target, SaveFormat.Doc);
return true;
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:8,代码来源:AsposeConverter.cs
示例14: DeserializeDatabase
private static void DeserializeDatabase(bool force)
{
foreach (string path2 in Factory.GetDatabaseNames())
{
var options = new LoadOptions { ForceUpdate = force, DisableEvents = true };
Manager.LoadTree(Path.Combine(PathUtils.Root, path2), options);
}
}
开发者ID:WSlama,项目名称:Sitecore-Mobile-Device-Detector,代码行数:8,代码来源:Deserialize.aspx.cs
示例15: XmlActionResult
public XmlActionResult(string xml, string fileName,
EncodingType encoding = EncodingType.UTF8,
LoadOptions loadOptions = System.Xml.Linq.LoadOptions.None)
{
XmlContent = xml;
FileName = fileName;
Encoding = encoding;
LoadOptions = loadOptions;
}
开发者ID:sabotuer99,项目名称:ExtensibilityMVC,代码行数:9,代码来源:XmlActionResult.cs
示例16: GetTargetDatabase
private static string GetTargetDatabase(string path, LoadOptions options)
{
if (options.Database != null)
{
return options.Database.Name;
}
string path2 = PathUtils.UnmapItemPath(path, PathUtils.Root);
ItemReference itemReference = ItemReference.Parse(path2);
return itemReference.Database;
}
开发者ID:jelleovermars,项目名称:Unicorn,代码行数:10,代码来源:SerializationLoader.cs
示例17: ConverToImage
/// <summary>
/// Word转为图片
/// </summary>
/// <param name="source">word文件路径</param>
/// <param name="target">图片保存的文件夹路径</param>
/// <param name="resolution">分辨率</param>
/// <param name="format">图片格式</param>
public static bool ConverToImage(string source, string target, int resolution = 300, AsposeConvertDelegate d=null)
{
double percent = 0.0;
int page = 0;
int total = 0;
double second = 0;
string path = "";
string message = "";
DateTime startTime = DateTime.Now;
if (!FileUtil.CreateDirectory(target))
{
throw new DirectoryNotFoundException();
}
if (!File.Exists(source))
{
throw new FileNotFoundException();
}
if (d != null)
{
second = (DateTime.Now - startTime).TotalSeconds;
percent = 0.1;
message = "正在解析文件!";
d.Invoke(percent, page, total, second, path, message);
}
LoadOptions loadOptions = new LoadOptions();
loadOptions.LoadFormat = LoadFormat.Auto;
Document doc = new Document(source, loadOptions);
total = doc.PageCount;
if (d != null)
{
second = (DateTime.Now - startTime).TotalSeconds;
percent = 0.2;
message = "开始转换文件,共" + total + "页!";
d.Invoke(percent, page, total, second, path, message);
}
logger.Info("ConverToImage - source=" + source + ", target=" + target + ", resolution=" + resolution + ", pageCount=" + total);
for (page = 0; page < total; page++)
{
ImageSaveOptions options = new ImageSaveOptions(SaveFormat.Png);
options.PrettyFormat = false;
options.Resolution = resolution;
options.PageIndex = page;
options.PageCount = 1;
path = target + "\\" + (page + 1) + ".png";
doc.Save(path, options);
if (d != null)
{
second = (DateTime.Now - startTime).TotalSeconds;
percent = 0.2 + (page + 1) * 0.8 / total;
message = "正在转换第" + (page + 1) + "/" + total + "页!";
d.Invoke(percent, (page + 1), total, second, path, message);
}
}
return true;
}
开发者ID:limingnihao,项目名称:Net,代码行数:62,代码来源:WordUtil.cs
示例18: Load
public static XRootNamespace Load(string xmlFile, LoadOptions options)
{
XRootNamespace root = new XRootNamespace();
root.doc = System.Xml.Linq.XDocument.Load(xmlFile, options);
XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
if (typedRoot == null)
{
throw new LinqToXsdException("Invalid root element in xml document.");
}
root.rootObject = typedRoot;
return root;
}
开发者ID:davelondon,项目名称:dontstayin,代码行数:12,代码来源:XRootNamespace.cs
示例19: Load
public static XRoot Load(TextReader textReader, LoadOptions options)
{
XRoot root = new XRoot();
root.doc = System.Xml.Linq.XDocument.Load(textReader, options);
XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
if (typedRoot == null)
{
throw new LinqToXsdException("Invalid root element in xml document.");
}
root.rootObject = typedRoot;
return root;
}
开发者ID:davelondon,项目名称:dontstayin,代码行数:12,代码来源:XRoot.cs
示例20: Load
/// <summary>
/// This should be a part of the I/O layer
/// </summary>
/// <param name="loadOptions">Load options.</param>
/// <param name="inputUri">This could be a file or a url</param>
public static XDocument Load(string inputUri, LoadOptions loadOptions)
{
if (inputUri.Contains("://"))
{
using (Stream stream = UriResolver.GetStream(inputUri))
{
return XDocument.Load(stream, loadOptions);
}
}
return XDocument.Load(inputUri, loadOptions);
}
开发者ID:DBailey635,项目名称:C1-CMS,代码行数:17,代码来源:XDocumentUtils.cs
注:本文中的LoadOptions类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论