gpt4 book ai didi

c# - 获取 Excel 工作簿的路径或文件名

转载 作者:行者123 更新时间:2023-12-04 21:22:11 25 4
gpt4 key购买 nike

如何在下面的代码中获取工作簿的路径或文件名,以便我可以获取已编辑的工作簿。我在这里使用了 ExpertXLS – .NET 的 Excel 电子表格库 - C#/VB.NET

using ExpertXls;

namespace IQC
{
public class CSFB
{
public static string GenerateTemplateForCurrentGridView(IQO[] items, string colname, int icol)
{
/*Some Code here*/
string pathSource = HttpContext.Current.Server.MapPath("~/pdf/ExportTemplate.xlsx");
ExpertXls.ExcelLib.ExcelWorkbook workbook = new ExpertXls.ExcelLib.ExcelWorkbook(@pathSource);
workbook.LicenseKey = Inq.Configuration.Settings.Value("ExpertPdfLicenseKey");
ExpertXls.ExcelLib.ExcelWorksheet ws = workbook.Worksheets["ImportTemplate"];
ExpertXls.ExcelLib.ExcelCellStyle Style1 = workbook.Styles.AddStyle("Style1");
Style1.Fill.FillType = ExpertXls.ExcelLib.ExcelCellFillType.SolidFill;
Style1.Fill.SolidFillOptions.BackColor = Color.Yellow;
foreach (string cols in colname.Split(','))
{
ws[cols].Style = Style1;
}
/*Some Code here*/
}
}
}

最佳答案

您可以使用 Application.ActiveWorkbook.FullName如果工作簿是事件工作簿。您也可以尝试使用workbook.Path .引用 link .

关于c# - 获取 Excel 工作簿的路径或文件名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42757870/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com