TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sujeet Raman
864
927
352.9k
Opening excel file gives message box “content recovery of the work
Sep 16 2020 4:44 AM
While I'm trying to open excel file a message box is prompting like "
We found a problem with some content in file name. Do you want us to try to recover as much as we can? If you trust the source of this workbook, click Yes.
". I don't understand why this happened and none of the internet solution is not working for me. Can anyone help me?
public
static
string
OpenXML(
string
FolderPath, DataSet tableSet)
{
WorkbookPart wBookPart =
null
;
var datetime = DateTime.Now.ToString().Replace(
"/"
,
"_"
).Replace(
":"
,
"_"
);
string
FilePath =
""
;
foreach
(DataTable table1
in
tableSet.Tables)
{
if
(table1.Rows.Count != 0)
{
using
(SpreadsheetDocument spreadsheetDoc = SpreadsheetDocument.Create(FilePath, SpreadsheetDocumentType.Workbook))
{
wBookPart = spreadsheetDoc.AddWorkbookPart();
wBookPart.Workbook =
new
Workbook();
uint
sheetId = 1;
spreadsheetDoc.WorkbookPart.Workbook.Sheets =
new
Sheets();
Sheets sheets = spreadsheetDoc.WorkbookPart.Workbook.GetFirstChild();
WorkbookStylesPart wbsp = wBookPart.AddNewPart();
wbsp.Stylesheet = CreateStylesheet();
wbsp.Stylesheet.Save();
foreach
(DataTable table
in
tableSet.Tables)
{
if
(table.Rows.Count != 0)
{
table.TableName = table.Rows[0][
"LeaseCondition"
].ToString();
WorksheetPart wSheetPart = wBookPart.AddNewPart();
Sheet sheet =
new
Sheet() { Id = spreadsheetDoc.WorkbookPart.GetIdOfPart(wSheetPart), SheetId = sheetId, Name = table.TableName };
sheets.Append(sheet);
SheetData sheetData =
new
SheetData();
wSheetPart.Worksheet =
new
Worksheet();
Row headerRow =
new
Row();
Columns columns =
new
Columns();
int
ColumnNumber = 1;
foreach
(DataColumn column
in
table.Columns)
{
Cell cell =
new
Cell();
cell.DataType = CellValues.String;
cell.CellValue =
new
CellValue(column.ColumnName);
cell.StyleIndex = 2;
headerRow.AppendChild(cell);
Column column1 =
new
Column();
column1.Width = 30; ;
column1.BestFit =
true
;
column1.CustomWidth =
true
;
column1.Min = Convert.ToUInt32(ColumnNumber);
column1.Max = Convert.ToUInt32(ColumnNumber);
columns.AppendChild(column1);
ColumnNumber = ColumnNumber + 1;
}
wSheetPart.Worksheet.AppendChild(columns);
sheetData.AppendChild(headerRow);
foreach
(DataRow dr
in
table.Rows)
{
Row row =
new
Row();
foreach
(DataColumn column
in
table.Columns)
{
Cell cell =
new
Cell();
cell.DataType = CellValues.String;
cell.CellValue =
new
CellValue(dr[column].ToString());
cell.StyleIndex = 1;
row.AppendChild(cell);
}
sheetData.AppendChild(row);
}
sheetId++;
wSheetPart.Worksheet.AppendChild(sheetData);
}
}
}
}
}
return
FilePath;
}
Reply
Answers (
1
)
create identity provider call another saml2 identity provider
How to create @Html.TextAreaFor in c# asp.net mvc?