private static void MosaMosaAA() {
Excel.Application xlApplication = null;
try {
xlApplication = new Excel.Application();
xlApplication.Visible = true;
Excel.Workbooks xlWorkbooks = null;
try {
xlWorkbooks = xlApplication.Workbooks;
Excel.Workbook xlWorkbook = null;
try {
xlWorkbook = xlWorkbooks.Open (
@"C:\MakiMakiLove.xls",
System.Reflection.Missing.Value, System.Reflection.Missing.Value,
System.Reflection.Missing.Value, System.Reflection.Missing.Value,
System.Reflection.Missing.Value, System.Reflection.Missing.Value,
System.Reflection.Missing.Value, System.Reflection.Missing.Value,
System.Reflection.Missing.Value, System.Reflection.Missing.Value,
System.Reflection.Missing.Value, System.Reflection.Missing.Value,
System.Reflection.Missing.Value, System.Reflection.Missing.Value
);
object xlDocumentProperties = null;
try {
xlDocumentProperties = xlWorkbook.CustomDocumentProperties;
System.Type typeDocumentProperties = xlDocumentProperties.GetType();
object xlDocumentProperty = null;
try {
xlDocumentProperty = typeDocumentProperties.InvokeMember(
"Item",
System.Reflection.BindingFlags.GetProperty,
null,
xlDocumentProperties,
new object[] {"タイピスト"}
);
if (xlDocumentProperty == null) {
return;
}
System.Type typeDocumentProperty = xlDocumentProperty.GetType();
object propertyValue = typeDocumentProperty.InvokeMember(
"Value",
System.Reflection.BindingFlags.GetProperty,
null,
xlDocumentProperty,
null
);
if (propertyValue != null) {
MessageBox.Show("タイピストの値 == " + propertyValue.ToString());
}
} finally {
if (xlDocumentProperty != null) {
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlDocumentProperty);
}
}
} finally {
if (xlDocumentProperties != null) {
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlDocumentProperties);
}
}
} finally {
if (xlWorkbook != null) {
try {
xlWorkbook.Close(
System.Reflection.Missing.Value,
System.Reflection.Missing.Value,
System.Reflection.Missing.Value
);
} finally {
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlWorkbook);
}
}
}
} finally {
if (xlWorkbooks != null) {
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlWorkbooks);
}
}
} finally {
if (xlApplication != null) {
try {
xlApplication.Quit();
} finally {
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlApplication);
}
}
}
}
|