c# - 使用 C# 打开/保存 excel 文件时的问题
问题描述
我正在尝试使用 C# 访问 excel 模块,但在保存 excel 文件后遇到了问题。
有重复的 Thisworkbook 和 Sheets 如下图所示。
仅当 excel 文件具有模块时才会发生这种情况,而如果 excel 项目中只有工作表,一切都会好起来的。
这是代码,它只是打开和保存同一个文件。
我正在使用 WIN10/VS2013/EXCEL 2010。
有谁知道为什么会发生这种情况?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Excel = Microsoft.Office.Interop.Excel;
using Microsoft.Vbe.Interop;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
string filepath = @"C:\test.xls";
Excel._Application app = new Excel.Application();
Excel._Workbook workbook = app.Workbooks.Open(filepath);
workbook.SaveAs(filepath);
workbook.Close(true);
app.Quit();
}
}
}
解决方案
推荐阅读
- python - 检查客户端是否仍然连接 - 使用 UDP 的 Python 套接字编程
- google-drive-api - 如何在 Flutter 应用中集成 google drive?
- android - Android volley 图像加载导致我的服务器负载过重
- python - 当两列具有相同的值时查找 Delta - sql server
- python-3.x - 图像处理 - 将一个热编码标签分配给图像数组以进行训练
- javascript - 按钮 onclick 文档而不是在 JavaScript 文件中使用
- javascript - 对象不支持 React 中 IE11 中的属性或方法“scrollBy”
- html - 无论如何,引导垂直对齐都不起作用
- r - 检查日期是否在查找表的范围内
- functional-programming - Dart 中的 yield 示例