I am developing a Windows 8.1 application in Visual Studio 2013 to create an Excel Sheet at run time. Visual Studio doesn't show any error, but when I run the app, there is a run time error that is :
Error 1 Missing compiler required member
'System.Runtime.InteropServices.LCIDConversionAttribute..ctor' D:\GS\Projects\excel\excel\CSC excel
Here is my CS code :
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
namespace excel
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook workbook = null;
Microsoft.Office.Interop.Excel.Workbooks workbooks = null;
Microsoft.Office.Interop.Excel._Worksheet worksheet = null;
workbooks = excelApp.Workbooks;
workbook = workbooks.Add(1);
worksheet = (Microsoft.Office.Interop.Excel.Worksheet)workbook.Sheets[1];
excelApp.Visible = true;
worksheet.Cells[1, 1] = "Value1";
worksheet.Cells[1, 2] = "Value2";
worksheet.Cells[1, 3] = "Addition";
}
}
}
In the above code, there is no red line shown in VS-2013 for error.
I added references for Excel : Microsoft.Office.Interop.Excel
Does anyone have a solution ?
Sorry you can not automate office from a store app. I would look at using something like syncfusion's docio if you want to create a spread sheet
Related
I am very new to Telerik reporting and i am trying to create a c# console app which takes a simple trdp template file, inserts values into it from a JSON file during runtime and convert it into a pdf as output. Any help is appreciated as i am learning it from scratch.Thanks.
enter image description here
You can try the following C# code for console application, it takes trdp file and exports it to multiple formats, including PDF. You will find the exported documents in your console application Debug folder (if you run it in Debug configuration).
using System;
using System.Collections;
using System.IO;
using System.Linq;
using Telerik.Reporting;
using Telerik.Reporting.Processing;
namespace ConsoleApp2101
{
class Program
{
static void Main(string[] args)
{
var reportSource = new UriReportSource();
var processor = new ReportProcessor();
var deviceInfo = new Hashtable();
reportSource.Uri = #"C:\Program Files (x86)\Progress\Telerik Reporting R1 2021\Report Designer\Examples\MyReport.trdp";
deviceInfo.Add("DocumentTitle", "SomeOptionalTitle");
string[] availableFormats = new string[] { "PDF", "CSV", "DOCX", "XLSX", "PPTX", "RTF" };
foreach (var format in availableFormats)
{
var result = processor.RenderReport(format, reportSource, deviceInfo);
if (result.HasErrors)
{
Console.WriteLine(string.Join(",", result.Errors.Select(s => s.Message)));
}
else
{
File.WriteAllBytes($"MyReport.{format.ToLower()}", result.DocumentBytes);
}
}
Console.WriteLine("Completed!");
Console.ReadKey();
}
}
}
Reference:
https://docs.telerik.com/reporting/programmatic-exporting-report
I'm aware this question has been asked already - but none provided a resolution.
I have read these links:
Xamarin Forum, Stack Overflow Q and some others.
I have a relatively simple project at the moment and I keep getting the error "The name 'Resource' does not exist in the current context"
I can restart the project & it will work and "resource" is underlined in red and I can still debug the project.
Then after a few tries it goes and complains that it's not in the current context.
I did not make any changes to the project - I have come back to it now from a while ago.
So I'm going to guess that updates to VS 2015 have broken it.
My Code example:
using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using Android.Views.InputMethods;
using Android.Graphics.Drawables;
using Android.Graphics;
namespace Designer
{
[Activity(Label = "Designer", MainLauncher = true)]
public class MainActivity : Activity
{
// Global Varialble
Button butSignIn;
EditText tbxUsername;
TextView txtErrorMsg;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
butSignIn = FindViewById<Button>(Resource.Id.butSignIn);
butSignIn.Click += ButSignIn_Click;
tbxUsername = FindViewById<EditText>(Resource.Id.txtUsername);
txtErrorMsg = FindViewById<TextView>(Resource.Id.txtErrorMessage);
ActionBar.SetDisplayShowTitleEnabled(false);
ColorDrawable colorDrawable = new ColorDrawable(Color.ParseColor("#ff70bc1e"));
ActionBar.SetBackgroundDrawable(colorDrawable);
}
private void ButSignIn_Click(object sender, System.EventArgs e)
{
if (tbxUsername.Text == "Azmodan")
{
Intent intent = new Intent(this, typeof(MenuActivity));
this.StartActivity(intent);
this.Finish(); // this will close the activity and will close app if we try go back
}
else
{
txtErrorMsg.Visibility = ViewStates.Visible;
txtErrorMsg.Text = "inccorect login details, please try again";
}
}
}
}
Any help would be appreciated.
The following works great on my local IIS and return videos. When I run it on my GoDaddy shared hosting website (using https), it returns "This page can't be displayed". My code is below and I have isolated the problem down to this statement:
// Execute search
SearchListResponse searchListResponse = searchListRequest.Execute();
I have searched but cannot find solution and even called GoDaddy for help but no joy yet. Hope someone can help resolve.
Here's the source code snippet:
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
//using Google.Apis.Auth.OAuth2;
using Google.Apis.Services;
using Google.Apis.Upload;
using Google.Apis.Util.Store;
using Google.Apis.YouTube.v3;
using Google.Apis.YouTube.v3.Data;
public void runSearch(string query)
{
try
{
// Create YouTube Service
YouTubeService youTubeService = new YouTubeService(new BaseClientService.Initializer()
{
ApiKey = "xxxx",
ApplicationName = this.GetType().ToString()
});
SearchResource.ListRequest searchListRequest = youTubeService.Search.List("snippet");
searchListRequest.Q = query;
searchListRequest.MaxResults = 15;
searchListRequest.Type = "video";
// Execute search
SearchListResponse searchListResponse = searchListRequest.Execute();
...
}
I wrote a selenium code to run automation in webpage via Firefox
I need to record the browser actions like a visual
Is there any way to record the screen on firefox as a video using addons or any other. I am using firefox version 34
You can include it in your test. Here is an example for C#. To make this work, you need to install Microsoft Expression Encoder and add the reference to your project
using Microsoft.Expression.Encoder.ScreenCapture;
string timestamp = DateTime.Now.ToString("dd-MM-yyyy-hh-mm-ss");
ScreenCaptureJob vidrec = new ScreenCaptureJob();
vidrec.OutputScreenCaptureFileName = #"C:/yourPathToSaveFile/yourFilename " + timestamp + ".wmv";
vidrec.Start();
// your test
vidrec.Stop();
http://learnseleniumtesting.com/recording-selenium-test-execution/
using System;
.
.
using OpenQA.Selenium;
.
.
using Microsoft.Expression.Encoder.ScreenCapture;
using System.Drawing;
using Microsoft.Expression.Encoder.Profiles;
using Microsoft.Expression.Encoder;
namespace FRAMEWORK
{
//Call this method in setup method.
public static void StartRecordingVideo()
{
//Provide setting in config file if you want to do recording or not.
if (testEInfo.isRecording)
{
job = new ScreenCaptureJob();
job.CaptureRectangle = Screen.PrimaryScreen.Bounds;
job.ShowFlashingBoundary = true;
//provide the location where you want to save the recording.
job.OutputPath = AutomationLogging.newLocationInResultFolder;
job.Start();
}
}
}
I'm new to .NET. I want to make a console application that converts a .pptx file into a .wmv.I've managed to do this using powerpoint interop.But i have some problems.First If i build the application and tranfer it to another computer i get an exception Error HRESULT E_FAIL has been returned for COM object(i have powerpoint in both PCs).If i run it on the one that i wrote it i everything works alright.But not for the first time.Meaning that when i start my pc and run it i'll get the same exception and the second time i'll try to run it will run properly.What could be the problem?iguess something with interop and powerpoint but i can't figure it out.
Ok here is the code:
using Microsoft.Office.Core;
using Microsoft.Office.Interop.PowerPoint;
using PowerPoint = Microsoft.Office.Interop.PowerPoint;
using System.Runtime.InteropServices;
using System.IO;
using System;
namespace Microsoft.Office.Interop.PowerPoint
{
class Program
{
static void Main(string[] args)
{
string fileName = args[0];
string exportName = args[1];
string exportPath = args[2];
Microsoft.Office.Interop.PowerPoint.Application ppApp = new Microsoft.Office.Interop.PowerPoint.Application();
ppApp.Visible = MsoTriState.msoTrue;
ppApp.WindowState = PpWindowState.ppWindowMinimized;
Microsoft.Office.Interop.PowerPoint.Presentations oPresSet = ppApp.Presentations;
Microsoft.Office.Interop.PowerPoint._Presentation oPres = oPresSet.Open(fileName,
MsoTriState.msoFalse, MsoTriState.msoFalse,
MsoTriState.msoFalse);
try
{
oPres.CreateVideo(exportName);
oPres.SaveCopyAs(String.Format(exportPath, exportName),
PowerPoint.PpSaveAsFileType.ppSaveAsWMV,
MsoTriState.msoCTrue);
}
finally
{
ppApp.Quit();
}
}
}
}
_Presentation.CreateVideo doesn't create a video out of a powerpoint. It creates a video inside of a powerpoint. That's what the documentation says, anyway.
Try _Presentation.SaveAs and then use PpSaveAsFileType.ppSaveAsWMV for the file type.