0

我正在将 excel 工作表转换为 html 文件。在某些情况下,某些列中添加了语音,我不希望它们在转换后的 html 文件中。如何在转换时删除这些语音......?有什么办法可以以编程方式关闭语音..?这是我正在使用的代码

xApp = new Microsoft.Office.Interop.Excel.Application();
object missing = Type.Missing;
object trueObject = true;
xApp.Visible = false;
xApp.DisplayAlerts = false;
xWorkBook = xApp.Workbooks.Open(ExcelFilePath, missing, trueObject, missing, missing, missing,
                    missing, missing, missing, missing, missing, missing, missing, missing, missing);
object format = Microsoft.Office.Interop.Excel.XlFileFormat.xlHtml;

ConveredFilesPath = Path.Combine(outputDirTemp, ExcelFileName);

string tempFileName = ConveredFilesPath + ".html";
xWorkBook.SaveAs(tempFileName, format, missing, missing, missing, missing,
                Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange,
                missing, missing, missing, missing, missing);
if(Directory.Exists(ConveredFilesPath+".files"))
    ConveredFilesPath += ".files";
else
    ConveredFilesPath += "_files";

for (int count = 1; count < xWorkBook.Sheets.Count + 1; count++)
{
    processDetils.AddFileInfo((count).ToString(), ((Microsoft.Office.Interop.Excel.Worksheet)xWorkBook.Sheets.get_Item(count)).Name);
}
CloseExcelObject(ref xWorkBook, ref xApp);

有什么办法可以Turned off在 Excel 对象中设置语音?这是演示excel文件的图片,粗体字符是拼音 在此处输入图像描述

在这里你可以清楚地看到一些单元格在顶部有语音但同样没有..

4

1 回答 1

0

根据我给出的想法,Me how我通过获取工作簿中的工作表数量解决了这个问题,然后在这里设置Phonetic.visible属性false 是代码

Excel.Worksheet NwSheet;
Excel.Range ShtRange;
//Getting Number of total sheets in workbook
int SheetCount = xApp.Sheets.Count;
for (int i = 1; i <= SheetCount; i++){
NwSheet = (Excel.Worksheet)xApp.Sheets.get_Item(i);
//Getting all used cells in sheet 
ShtRange = NwSheet.UsedRange;
// hiding phonetics from sheet
ShtRange.Phonetic.Visible = false;
}

所以现在语音在转换后的文件中不可见html......

于 2014-05-14T11:53:26.463 回答